Data structures: Binary Tree


See complete series on data structures here:

In this lesson, we have discussed binary tree in detail. We have talked about different types of binary tree like “complete binary tree”, “perfect binary tree” and “balanced binary tree” and their properties. We have also discussed how cost of operations in a tree may depend upon height of the tree and why we want a tree to be dense and its height to be minimum. Finally, we talked about two possible implementations of binary tree – a) using dynamically created nodes and b) using arrays.

For practice problems and more, visit:

Like us on Facebook:

Follow us on twitter:



  1. The height is the maximum depth of a leaf node in the graph! Height and depth can be the same when a node has as many ancestors as descendants 🙂

  2. Felt very sad that the guy who was founder of these courses passed away on June 2014 . in a car accident! but he is alive with his videos!!! RIP !! 🙁

  3. Your Voice is very clear but have some example while explaining this Tree mathematics, also slow down in between,don’t run away with all the lecture

  4. Question : What do you mean by complete binary tree at 5:18, Do you mean that all L0 – L2 nodes must have 2 children, or do you mean numerical fulfillment of nodes?

  5. This is a great video. Just had one doubt, i understood we consider height of node as 0 if there are no child nodes and height of tree as -1 if there is no root. However, around 13th minute we considered tree with no child nodes with height -1(instead of 0), also made height of left sub-tree as 1(instead of 2).

  6. thanks to making such a nice tutorial it will covers all necessary information to starting binary tree.
    thanks again.

  7. Thanks a lot for this data structure playlist! A life saver if u ask me..

    I know I know i'm pretty late.. but still thanks again!

  8. Ur videos r awesome………. But one simple request……..can u plz put that subtitles little down coz we can't see what is written on bottom of the board

  9. Great video but I would recommend going a little slower. The math is important and I think you went too fast on those parts. Thanks for the good work!

  10. If anyone is having confusion between depth and height, think of the analogy that we measure the 'depth' of sea from it's surface and the 'height' of a person from toe to head.

  11. I didn't understand the height of the subtree ..according to me it was two as u described at 13:05 min you previously said ..Height is the longest path from Node x to leaf ..and if you are counting from the root then what is the difference between depth and height ..oh God …its so confusing 🙂

  12. Dude height means no.of edges from node to the farthest leaf node??? But you are taking height as 1 from root to its child. is it correct?

  13. Based on this it would be safe to assume that using timestamp based primary keys is not a good idea in mysql? It uses b-trees for storing indexes. With id based indices you are essentially constantly building a linked list that mysql has to rebalance in the background. On a very hot table this would result in a lot of extra work necessary to keep read speed reasonable.

  14. Is that array implementation suitable for only perfect binary trees or is it suitable for complete binary trees too ?


Please enter your comment!
Please enter your name here