Question: Everything compiles and everything runs correctly except my insertionSort(). When the user selects it in the app class it just list the last input the

Everything compiles and everything runs correctly except my insertionSort(). When the user selects it in the app class it just list the last input the user made instead of showing the sorted list. HELP PLEASE!

public void insertionSort(DoublyLinkedList dd)

{

DoublyLinkedList newLink = dd; DoublyLinkedList temp = first; if( extra == null ) //if empty list, { first = newLink;//newLink <--last first.next = null; first.previous = null; } else{ DoublyLinkedList previous=null; DoublyLinkedList next=first.next; DoublyLinkedList current=first; for(int i=0;temp.next!=null;i++){ if(Integer.parseInt(temp.dData.getId()) < Integer.parseInt(newLink.dData.getId())){ current=temp; previous=temp.previous; next=temp.next; } temp=temp.next;} newLink.previous=temp; newLink.next=temp.next; temp.next=newLink; next.previous=newLink;}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!