Add a Bubblesort() method to the following LinkedList.java file: Please add othe
ID: 638016 • Letter: A
Question
Add a Bubblesort() method to the following LinkedList.java file:
Please add other appropriate methods/edits you think may be necessary
class Node{
int data;
public Node next;
public Node (int data){
this.data = data;
}
public void display(){
System.out.println(data);
}
}
public class LinkedList
{
private Node head, previous, current;
public LinkedList()
{
head = null;
}
public boolean isEmpty()
{
return( head==null);
}
public void insertFirst(int data)
{
Node newNode = new Node(data);
newNode.next = head;
head = newNode;
}
public Node deleteFirst()
{
Node temp = head;
head = head.next;
return temp;
}
public void displayList()
{
System.out.println("First to last: ");
current = head;
while(current != null)
{
current.display();
current = current.next;
}
System.out.println("");
}
}
Explanation / Answer
public void bubbleSort { for (int i = 0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.