(Solved) : Write Java Class Implement Generic Linked List List Must Implemented Singly Linked List Ge Q42705478 . . .

  1. Write a Java Class to Implement a Generic LinkedList

Your list must be implemented as asinglylinked list of generic nodes,where each Node object has two instance variables: an object of the“type variable” class, and a pointer to the next node on thelist.

Your class will contain separatemethods to handle each of the operations read from a data file (seeII., below)

Your class will also overridetoString() to return the objects on the list in the orderin which they occur.

  1. Write a Test Class for Your LinkedListClass

Your main method will readlist operation instructions from a data file until end-of-file andcall the appropriate method to execute each one.

After each operation is executed,print out the operation and the updated list.

The data file to be used is on theclass web site and the operations are:

  1. APPEND X – Append object X to the end of thelist   
  2. ADD N X – Insert object X as the new Nthelement in the list, increasing the size of the list by 1

E.g. Suppose the list is:

     head-> 1 -> 2 -> 3 -> 4 ->null

After ADD 3 7 itwould be:

     head-> 1 -> 2 -> 7 -> 3 -> 4-> null

  1. DELETE N – Remove the Nth object from thelist
  2. SWAP M N – Interchange the positions of theMth and Nth objects on the list

For credit, the two nodes mustactually “trade places” in the list, and not merely swap their datavalues

  1. REVERSE – Reverse the order of the objects onthe list

This must be done by reversing theorder of the nodes themselves, rather than by swapping the datastored

To get credit for yourreverse() method, it must use either one of these 2algorithms:

  1. For each node on the list except the current “head” node,delete the node and insert it as the newhead    
  2. Use your swap() method

6. CLEAR – Clear thelist (make it empty)

No credit will be given for programs that use anyadditional data structures – either from the Java API or programmerdefined -, other than your own LinkedList class

  1. It is not necessary to create aniterator for your list

An iterator allows the user of acollection to access each object stored without having to knowanything about how the collection is implemented. For thisassignment, the client does not require that capability.

Expert Answer


Answer to Write a Java Class to Implement a Generic Linked List Your list must be implemented as a singly-linked list of generic …

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?