Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please help with steps 10 and 11 in java thanks ! I. Requirements 1. Design and implement the IntNode class and put it to IntNode.java
please help with steps 10 and 11 in java thanks !
I. Requirements 1. Design and implement the IntNode class and put it to IntNode.java with the following detailed requirements. (1) (5 pts) This class has two instance variables: One instance variable is for keeping an integer value, and the other instance variable is a link pointing to another Int Node instance or pointing to null. You should NOT add any new instance variables. (2) (5 pts) The no-argument constructor which sets the node value to be 0 and the link to be null reference. public IntNode () (3) (5 pts) A constructor with the given node value and the link. public IntNode (int__data, IntNode _node) (4) (5 pts) Get and set methods to get the node value and node link. (5) (5 pts) toString method publie string tostring() This method should retum a String for the linked list starting from the node that activates this method. e.g., if the head node of Figure 1 activates this method, the output should be 12>28>0>34 If the third node of Figure 1 activates this method, it should output 0>34 Figure 1: An example linked list (6) (5 pts) A method to add a node after the current node. public void addNodefterThis (int newdata) This method should create a new node with value newdata and let the current node's link point to this new node. For instance, if the current node contains content 5 and its link points to another node with content 10. 510 Then, activating addNodeAfterThis (20) from the node with content 5 will generate a new list 5>20>10 (7) (5 pts) A method to remove the node after the current node. public void removeNodeAt terthis i) This method should remove the node that this node's link points to. (8) (5 pts) A method to get the number of nodes in the list starting from a given node head. publie statie int 1 stlength (IntNode head) (9) (5 pts) A method to search whether a linked list starting with head contains a given value data. publie statie boolean seareh (Int.Node head, Int data) This method returns true if data exists in the linked list starting with head; it returns false otherwise. Precondition of this method is that head is not null. (10) (20 pts) A method to sort the linked list in an increasing order. The smallest integer is in the node at the head of list. Your method should preserve repetitions of integers. If the original list had any integers occurring more than once, then the changed list will have the same number of each integer. For example: Input: 6>8>554>1>>6>NULL Output: 14>4>>5>5>6>6>8>>NULL Use the following specification: /"postconditiont the return value ta a head reterence ot a liniced liat with exact.ly the sane eatrien as the eriginal iint inneluding repetitions, if any\}, but the entries in this liat are sorted from amallest to largest. The original linked list is no longer available.,/ pubile statie IntNode iistsort (lntkode head) Your method will implement the following algoeithm (which is often called selection sort): The algorithm removes nodes one at a time from the original list and adds the nodes to a second list until all the nodes have been moved to the second list. The second list will then be sorted. Here is the pseudo code for selection sort: //Pseuado code for selection sort. while (the first list still has some nodes) 1 1. Find the node with largeat element of all the nodes in the first 1 ist. 2. Remove this node from the first 1 ist. 3. Add this tode at the head of the recond 1 ist. 1 Note that your method will move entire nodes, not just elements, to the second list. Thus, the first list will get shorter and shorter until it is an empty list. Your method should not need to use the now operator since it is just moving nodes from one list to another (not creating new nodes). 2 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