You are viewing a single comment's thread. Return to all comments →
What do you think of my solution?
Node SortedInsert(Node head,int data) { Node temp = head; while (temp != null) { if (temp.next == null || temp.next.data >= data) { Node node = new Node(); node.data = data; node.next = temp.next; node.prev = temp; if (temp.next != null) { temp.next.prev = node; } temp.next = node; break; } temp = temp.next; } 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 →
What do you think of my solution?