You are viewing a single comment's thread. Return to all comments →
What about this???
public static DoublyLinkedListNode sortedInsert(DoublyLinkedListNode llist, int data) { DoublyLinkedListNode temp = llist; DoublyLinkedListNode newNode = new DoublyLinkedListNode(data); if(data < temp.data){ newNode.next = llist; llist.prev = newNode; return newNode; } for(;temp.next != null && temp.data < data; temp = temp.next); if(temp.next == null && temp.data < data){ newNode.prev = temp; temp.next = newNode; } else{ newNode.prev = temp.prev; newNode.prev.next = newNode; newNode.next = temp; temp.prev = newNode; } return llist; }
Seems like cookies are disabled on this browser, please enable them to open this website
Inserting a Node Into a Sorted Doubly Linked List
You are viewing a single comment's thread. Return to all comments →
What about this???