Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part I: Implement a Single linked list to store a set of Integer numbers ( no duplicate ) ( 1 0 0 points ) Instance
Part I: Implement a Single linked list to store a set of Integer numbers no duplicate points
Instance variable
Constructor
Accessor and Update methods
Define a Node Class.
a Instance Variables
E elementgenerics framework
Node Next pointer refer to the next node Selfreferential
b Constructor
c Methods
E getElementReturn the value of this node.
setElementE e Set value to this node.
Node getNextReturn the pointer of this node.
setNextSetpoertothisnode.
displayNodeDisplay information of this node.
Define SLinkedList Class
a Instance Variables:
Node head
Node tail
int size
b Constructor
c Methods
int getSizeReturn the number of nodes of the list.
boolean isEmptyReturn true if the list is empty, and false otherwise.
int getFirstReturn the value of first node of the list.
int getLastReturn the value of Last node of the list.
Node getHeadReturn the head
setHeadNode hSet the head
Node getTailReturn the tail
setTailNode Set the tail
addFirstaddnewelementtothefrontofthelist
e add new element to the end of the list
E removeFirst Return the value of the first node of list
displayprint out values of all the nodes of the list
Node searchE keycheck if a given is in the list, return found nodes or null
Node updateE key, E eupdate the value of a given to new value, return updated node
Define TestSLinkedList Class
a Declare an instance of Single List class.
b Test all the methods of Single List class.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started