The following text is snippet from algorithms book.
We could draw the binary trees using rectangular boxes that are customary for linked lists, but trees are generally drawn as circles connected by lines because they are actually graphs. We also do not explicitly draw NULL links when referring to trees because every binary tree with N nodes would require N+1 NULL links.
My question is what does author mean every binary tree with N nodes would require N+1 null links? how author came with N+1 number?
If you have a tree of 1 node, there are 2 null links (left and right on the root). If you add a node to either left or right, you have filled 1 null and added 2 more. This continues on ad infinitum, therefore for each node added you net 1 extra null leaf.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With