Answers for "how to Inserting a Node Into a Sorted Doubly Linked List"

-1

how to Inserting a Node Into a Sorted Doubly Linked List

class DoublyLinkedListNode:
    def __init__(self, node_data):
        self.data = node_data
        self.next = None
        self.prev = None

def sortedInsert(head, data):
    node = DoublyLinkedListNode(data)
    if (head == None):
        return node
    elif (data < head.data):
        node.next = head
        head.prev = node
        return node
    else:
        node = sortedInsert(head.next, data)
        head.next = node 
        node.prev = head
        return head
Posted by: Guest on March-03-2021

Code answers related to "how to Inserting a Node Into a Sorted Doubly Linked List"

Python Answers by Framework

Browse Popular Code Answers by Language