You are viewing a single comment's thread. Return to all comments →
solution in python
def sortedInsert(head, data): cur=head node=DoublyLinkedListNode(data) if cur.data>data or cur.data==data: node.next=cur cur.prev=node head=node return head while cur.next: if (cur.data<data and cur.next.data>data) or cur.data==data: node.next=cur.next cur.next.prev=node node.prev=cur cur.next=node return head cur=cur.next if cur.data<data or cur.data==data: node.prev=cur cur.next=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 →
solution in python