You are viewing a single comment's thread. Return to all comments →
Python
def sortedInsert(llist, data): head = llist if llist.data > data: #board case head = DoublyLinkedListNode(data) head.next = llist else: while llist.next: prev = llist next_node = llist.next if next_node.data > data: new_node = DoublyLinkedListNode(data) new_node.next = next_node next_node.prev = new_node prev.next = new_node return head llist = next_node if llist.next == None: #board case new_node = DoublyLinkedListNode(data) new_node.prev = llist llist.next = new_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 →
Python