public void SetPreviousNode(DoublyLinkedListNode doublyLinkedListNode) { previous = doublyLinkedListNode; }
public void SetNextNode(DoublyLinkedListNode doublyLinkedListNode) { next = doublyLinkedListNode; }
private static void PrintVerticalSumInBinaryTree(BinaryTreeNode binaryTreeNode, DoublyLinkedListNode doublyLinkedListNode) { if (binaryTreeNode == null) { return; } else { doublyLinkedListNode.SetDoublyLinkedListNodeData( binaryTreeNode.GetBinaryTreeNodeData() + doublyLinkedListNode.GetDoublyLinkedListNodeData()); if (binaryTreeNode.GetLeft() != null) { if (doublyLinkedListNode.GetPreviousNode() == null) { doublyLinkedListNode.SetPreviousNode( new DoublyLinkedListNode(0) ); doublyLinkedListNode.GetPreviousNode(). SetNextNode(doublyLinkedListNode); } PrintVerticalSumInBinaryTree(binaryTreeNode.GetLeft(), doublyLinkedListNode.GetPreviousNode()); } if (binaryTreeNode.GetRight() != null) { if (doublyLinkedListNode.GetNextNode() == null) { doublyLinkedListNode.SetNextNode( new DoublyLinkedListNode(0) ); doublyLinkedListNode.GetNextNode() .SetPreviousNode(doublyLinkedListNode); } PrintVerticalSumInBinaryTree(binaryTreeNode.GetRight(), doublyLinkedListNode.GetNextNode()); } } }