Question: Please Help With This Programming Project Please 1. Implement a generic class MoveToFrontT that maintains a collection of items of generic type T in LIFO

Please Help With This Programming Project Please

1. Implement a generic class MoveToFrontT that maintains a collection of items of generic type T in LIFO order (last-in rst-out) without duplicates. (Similar to a Stack but without duplicates.) Use the class LinkedListT in the Java API to implement MoveToFront. Your class must provide the following instance methods. push: that adds an item to the collection, removing previous occurrences. pop: that removes the item added the latest to the collection. contains: that returns true if a given item is in the collection, or false otherwise. isEmpty?: that returns true if the collection is empty, or false otherwise.

2. Write a testMTF class with a main() method that tests all operations of the MoveToFront class above. Override the toString() method of the class Object, and use it to display all the items in the collection after each method is called.

3. Compute the big-O running time of each instance method, explaining the running time (basic operation counted, number of iter- ations in loops, etc.)

4. Now assume that MoveToFront was implemented with ArrayList instead of LinkedList. Re-compute the big-O running time of each instance method, explaining the running time (basic operation counted, number of iterations in loops, etc.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!