Question: ------------ public class IntLinkList { private IntNode top; //The reference to the first Node //=========== Solution code ============================= public IntLinkList(int[] data){ for (int i =

------------
public class IntLinkList { private IntNode top; //The reference to the first Node //=========== Solution code ============================= public IntLinkList(int[] data){
for (int i = 0; i public boolean empty(){ if (top == null) return true; return false; } public int first(){ return top.getData(); } public void removeFirst(){ if (top != null) top = top.getLink(); } public IntLinkList clone(){ IntLinkList a = new IntLinkList(); if (top != null){ IntNode p = top; while (p != null){ a.add(p.getData()); p = p.getLink(); } } return a; } private static boolean equals(IntNode top1, IntNode top2){ //Your code here return false; //Dummy statement for testing - remove it. } //=========== Supplied code ============================= public IntLinkList() { //A constructor that creates an empty list. top = null; } public void add(int newItem) { //Add the newItem at the FRONT of the list. top = new IntNode(newItem,top); }//add public String toString() { String answer = ">"; } public void ordInsert(int newItem) { //Add the newItem so that the list remains sorted into //ascending order. This will not work unless the list //is currently in ascending order. IntNode prev = null; IntNode next = top; while(next!=null && next.getData()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
