+ 4
Did anybody implement Binary Search tree as map Abstract data type in c or is that on any book? Could you share on this post
Did anybody implement Binary Search tree as map Abstract data type in c or is that on any book? Could you share on this post, because, I need to fix my methods in c
1 Respuesta
+ 3
You can implement binary trees as lists:
If you are at list position `n`, the left child node is at `2*n` and the right child node is at `2*n+1`.
So for example, the tree
1
2 3
4 5 6 7
Could be written as the list [1,2,3,4,5,6,7].
Similarly if you are at any node `n` and you need to find the parent, just divide by 2 :)