private DllNode FindLastNode(DllNode node) { if (node.next != null) { return(FindLastNode(node.next)); } else { return(node); } }
internal void Print(DllNode node) { if (node == null) { Console.WriteLine(" Done."); return; } Console.Write(node.item + " "); Print(node.next); }
public void AddNode(DllNode node) { if (root == null) { root = node; } else { var lastNode = FindLastNode(root); lastNode.next = node; node.prev = lastNode; } }
public void ConvertBTreeToDllInorder(Node node, DoubleLinkedList dllTree) { if (node == null) { return; } ConvertBTreeToDllInorder(node.left, dllTree); // first recursively convert left subtree var dllNode = new DllNode(node.item); dllTree.AddNode(dllNode); ConvertBTreeToDllInorder(node.right, dllTree); // now recur on right child }
public DllNode(int item) { this.item = item; prev = null; next = null; }