[algogeeks] vertical level sum in Binary tree

2012-01-19 Thread Coding Geek
Given a binary tree with no size limitation, write a program to find the sum of each vertical level and store the result in an appropriate data structure (Note: You cannot use an array as the tree can be of any size). 4

Re: [algogeeks] Amazon Interview Question

2012-01-19 Thread Coding Geek
;ja.length-i-1;j++){ if(a[j]==0 a[j+i+1]==0){ a[j]=i; a[j+i+1]=i; put(a, i-1); a[j]=0; a[j+i+1]=0; } } }else if(i==0){ for (int k : a) { System.out.print(k + ); } System.out.println(); } } On Wed, Jan 18, 2012 at 10:04 PM, Coding Geek codinggee...@gmail.comwrote: Place N number

Re: [algogeeks] Amazon Interview Question

2012-01-19 Thread Coding Geek
@all Please check the Backtracking examples at http://www.geeksforgeeks.org/archives/tag/backtracking. You will understand the logic. In this examples first we fix a no. onto some position. After we check for other no. if any of the no. do not fit according to property we move back and reset all

[algogeeks] Amazon Interview Question

2012-01-18 Thread Coding Geek
Place N number from 1 to N, in 2N positions in such a way so that there are Exactly ā€œnā€ number of cells between two placed locations of number ā€œnā€. Write a program to display numbers placed in this way. Example:- (1) One of the possible placement for 7 numbers in 14 positions is : 5 7 2 3 6 2 5