Reference no: EM132468437
Assignment
Question 1. Write separate programs for the following exercises in Python. Each file should have your name at the top in comment, with short description of what is implemented in that file. Make sure your files have appropriate names as indicated in each exercise. Programs should write output to the Console and have hard coded input in main.
Part a) DLinkedList:
• Add new operation to DLinkedList called subList with single parameter for Vehicle's model. The operation should find all the vehicles with that model and return the Vehicle instances as a list object. If no vehicles are found it should return an empty list.
• Modify the code in DLinkedList so that no duplicate vehicle objects can be added based on vin value. Note: you cannot add any new class members. You can only modify existing functions and/or add new functions. When there is an attempt to add a duplicate vehicle, the operation should raise an exception with meaningful message.
• Add new operation to DLinkedList called addList with single parameter which is another DLinkedList instance. The operation should attach the parameter's list to the end of itself. If the parameter's list is None, the operation should raise an exception with meaningful message.
• Analyze in writing, explaining all calculations and final grow rate, time and space complexity of the new operations to include best, average, and worst case
• Write test program (TestDLinkedList class) which creates an instance of the DLinkedList and calls all the new operations to demonstrate they work correctly.
• Video: Explain the new operation design and implementation, show the program running, and explain output
Part b) ConvertToArray:
• Write a program with a method that takes a DLinkedList instance as a parameter and another string parameter filter. It then copies every Vehicle object in the parameter list whose vin value contains the filter value, to the array called vehicleArray.
• The method must check if the parameters are None or list is empty and raise an exception with meaningful message if it is. At the end of the method execution, the parameter list instance must remain unchanged. The method should return the vehicleArray.
• Analyze in writing, explaining all calculations and final grow rate, time and space complexity of the method to include best, average, and worst case
• Write a main method to test the code - both for valid and invalid parameters.
• Video: Explain the design and implementation of convertToArray method, show the program running, and explain output
Part c) Queue/Stack:
• Add peek operation to return the Vehicle to be deQueue(ed) next without removing it
• Add peek operation that has no parameters and returns Vehicle object that would be pop()ed but without removing
• Analyze in writing, explaining all calculations and final grow rate, time and space complexity of the peek operations to include best, average, and worst case
Part d) Queue/Stack usage: Write a program with two functions as follow:
• Method addYear takes an instance of a Queue (populated with Vehicle objects) and returns a new Stack instance where each vehicle's year was incremented by one and is in the same order as the Queue. The method can only use the
Queue/Stack's operations to access data. If parameter is None it should throw an exception. The Queue instance in the parameter should be unchanged at the end of the method.
• Method countMake takes an instance of a Stack (populated with Vehicle objects) and string value for make, returns a new Queue instance with the vehicle objects that match the make. The method can only use the Queue/Stack's operations to access data. If any parameter is None it should throw an exception. The Stack instance in the parameter should be unchanged at the end of the method.
• Write test main method to demonstrate that the above methods work correctly
• Analyze in writing, explaining all calculations and final grow rate, time and space complexity of the methods to include best, average, and worst case
• Video: Explain methods, run program and explain output.
Question 2. Stack1 (manual): A letter means doing a push operation and an asterisk means doing a pop operation n the below sequence. Manually determine and give the sequence of letters which are returned by the pop operations when this sequence of operations is performed on an initially empty stack.
AB*C**F*GH**
Question 3. Stack2 (manual): Given an empty stack in which the values A, B, C, D, E, F etc. are pushed on the stack in that order but can be popped at any time, manually determine and give a sequence of push and pop operations which results in pop()ed order of BEDCGFA
Question 4. Record a video(s) 15-25 min long going over the exercises as indicated above. You may have two separate videos if you need more time to explain all exercises. DO NOT create separate videos for each exercise!
Attachment:- Python Programming.rar