You are viewing a single comment's thread. Return to all comments →
Node SortedInsert(Node head,int data) { Node node = new Node(); node.data = data; Node next = head; Node prev = null; if(head == null) { return node; } while(next != null && next.data < data) { prev = next; next = next.next; } if(next == null) { node.prev = prev; prev.next = node; } else { prev.next = node; node.prev = prev; node.next = next; next.prev = node; } return head; }
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 →