KyaPoocha.com

Huge Collection of Interview Questions


Is it possible to implement trees using arrays ? If yes, how? 

Yes, it is possible.
Here is an example of implementing a binary tree:

Consider an attay : a[n];
Place the root in first position.
and let the current position to be i = 0;
place left node at the position: 2i+1
place right node at the position: 2i+2.
Repeat these steps.



If you liked this question/asnwer, make sure you
Subscribe to KyaPoocha.com RSS feed!


BOOKMARK THIS : BlinkList | del.icio.us | Digg it | Furl | reddit | StumbleUpon | Yahoo MyWeb |