Menu

[Solved]Designing Implementing Two Classes Node Class Linked List Class May Also Another Class Mai Q37199842

You will be designing and implementing two classes: a nodeclass, and a linked list class. You may also have another classwith the main method, or you can put your main method in the classwith the List.

Node class:

Two private fields: int data and a reference to the nextnode.

Public accessors/mutators for both the fields.

Three verisons of the constructors: no parameters, one parameterfor the data field, two parameters for the two fields.

Linked List Class:

The linked list will be singly linked as defined by the Nodes,since they declare the references. The linked list class willprovide the following methods to act on a linked list of nodes:

append(): Adds the new node to the endof the list.

prepend(): Adds the new node to thebeginning of the list.

insertAfter(): Adds the new node tothe nth position in the list.

removeAfter(Node n): Removes the noden (compare by value of the node, not position) in the list. Theuser can remove the head by passing in null (Node null).

getLength(): Returns the number ofnodes in the list.

Testing Your List:

You will need to make a test class that uses the abovenode/linked list. Your test class does not have to take user input(i.e. you don’t need to make a menu with a while loop) and insteadcan hard code the creation of the list and testing operations(appending, etc). I will collect your code to grade.

Expert Answer


Answer to You will be designing and implementing two classes: a node class, and a linked list class. You may also have another cla… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *