Hi ,
We can do Breadth first search but without any additional Memory like Queue.
Since we connect the siblings we can traverse through siblings.
Going from Top to bottom, Each Internal node(non-leaf) must connect its
children. If that internal node has a right sibling then connect the right
most
Something like this
1
2 3
4 5 67
1
|
2-3
|
4-5-6-7
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group,
use BFS traversal method
-- Prashant Kulkarni
|| Lokaha Samastaha Sukhino Bhavanthu ||
|| Sarve Jana Sukhino Bhavanthu ||
On Wed, May 12, 2010 at 8:48 PM, vinayan c vinayan1...@gmail.com wrote:
Something like this
1
2 3
4
do bfs.
On 13 May 2010 09:18, vinayan c vinayan1...@gmail.com wrote:
Something like this
1
2 3
4 5 67
1
|
2-3
|
4-5-6-7
--
You received this message because you are
Do a breadth first search on the tree and link all nodes at the same
level in the order that you process them
--Anurag
On Thu, May 13, 2010 at 9:18 AM, vinayan c vinayan1...@gmail.com wrote:
Something like this
1
2 3
4 5
it looks like left child right sibling relation ??? isn't it ?
On Thu, May 13, 2010 at 9:18 AM, vinayan c vinayan1...@gmail.com wrote:
Something like this
1
2 3
4 5 67
1
|
2-3
|
4-5-6-7
This can be done with level order traversal of the tree
Algorithm
count = count2 = 0
1. Push the root in the queue.
2. keep count at each level for root count =1
3. while(queue not empty)
4. push all childs of node at the top of queue in queue
5. count2 += (number of childs of node at