Vertical Sum of a Binary Tree

please explain doubly linked list method in words Anonymous - Apr 6, 2014please explain doubly linked list method in words Added the basic algo for that: 1. Start with the root node and empty double list listNode 2. Add the value of the rootNode to the current listNode 3. Now whenever you go left, pass listNode.left and root.left and call step1 and 2 recursively. 4. Similarly for right node Please let me know if I have not explained it properly. [Read More]

Vertical Sum of a Binary Tree

Question : Find vertical sum of given binary tree. Example: 1 / \\ 2 3 / \\ / \\ 4 5 6 7 The tree has 5 vertical lines Vertical-1: nodes-4 => vertical sum is 4 Vertical-2: nodes-2 => vertical sum is 2 Vertical-3: nodes-1,5,6 => vertical sum is 1+5+6 = 12 Vertical-4: nodes-3 => vertical sum is 3 Vertical-5: nodes-7 => vertical sum is 7 We need to output: 4 2 12 3 7 [Read More]