JAVA on netbeans write a method that sorts a linked list this method is not help
ID: 3718394 • Letter: J
Question
JAVA on netbeans
write a method that sorts a linked list
this method is not helpfull. Please need the output
private class Node{
int data;
Node link;
public Node(){
data = Int.minimum_val;
link = null;
}
public Node(int a, Node x){
data = a;
link = x;
}
}
// End of Node class
public Node head;
public LinkedList11(){
head = null;
}
public void insertAscending(int data){
Node node = new Node();
node.data = data;
if (head == null)
head = node;
Node p = head;
while (p.link != null)
{
if (p.link.data > data)
{ node.link = p.link;
p.link = node;
break;
}
p= p.link;
}
}
}
Explanation / Answer
Please find my implementation.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.