private static DoublyLinkedList <T> Merge(DoublyLinkedList <T> left, BiNode <T> parent, DoublyLinkedList <T> right) { // Doubly Linked List from left becomes the beginning of the new doubly linked list // parent goes to the middle // Doubly linked list from right becomes the end of the new doubly linked list if (left != null) { left.Tail.Node2 = parent; parent.Node1 = left.Tail; } else { parent.Node1 = null; } if (right != null) { right.Head.Node1 = parent; parent.Node2 = right.Head; } else { parent.Node2 = null; } return(new DoublyLinkedList <T>(left == null ? parent : left.Head, right == null ? parent : right.Tail)); }
public DoublyLinkedList <T> ConvertFromBinarySearchTree(BinarySearchTree <T> tree) { return(DoublyLinkedList <T> .ConvertFrom(tree)); }