Binary Trees

TIP: To crack algorithms on binary search trees we need to be good at recursion, usage of queues and usage of stacks. Imagining the traversal of BST is important and then decide whether to use queue or stack based on the traversals.

find depth of binary search tree We can find the depth of binary tree in three different recursive ways; 1. using instance variables to record current depth and total depth at every level….

print level wise nodes in the binary tree This can be achieved using breadth first traversal algorithm. 1. push level wise nodes into the queue at every iteration. 2. pop the node from queue at every iteration and print its value