Interview Question
Country: India
after running the code ; answer is :
1 6 8
2 8 4
1 4 10
3 4 5
1 9 5
2 5 7
1 7 7
@lucy : can u explain plz...
@anonymous--Create a tree like structure
crazy(3,4,5)
/ \
crazy(2,8,4) crazy(2,5,7)
/ \ / \ crazy(1,6,8) crazy(1,4,10) crazy(1,9,5) crazy(1,5,7)
After this u will get zeros in crazy(0 , -, -).So now how will u print it i,e in what manner.after crazy (1,6,8) wil be called it return becoz .n=0 so prints it.Think like inorder..
U will print first 1 6 8 den move to the called function
print 2 8 4 den 1 4 10 den move upwards..den root one 3 4 5 den similiarly in right subtree 1 9 5
2 5 7
1 7 7
Which company?
- Anonymous September 15, 2012