Re: [algogeeks] Amazon Placement Question

2010-08-02 Thread karthik ramanathan
@Ram and Nikhil What kind of traversal you will use to visit each node. How come you will get to know about teh number of nodes at each level that needs to be connected. RK On Sun, Aug 1, 2010 at 2:56 AM, Nikhil Jindal fundoon...@yahoo.co.inwrote: @Ram Kumar: Yes. Simple and affective. Just

Re: [algogeeks] Amazon Placement Question

2010-07-30 Thread karthik ramanathan
Do a BFS, by having a queue and keep inserting the nodes into it. You should know how many nodes are there in each level, for which you can have a variable to count the number of nodes in each level. The when you remove from your queue do connect these nodes till your count. You may need to use