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.

spiral traversal of binary tree: This can be done using two stacks in iterative manner. The below diagram depicts the spiral traversal of BST …

algorithm to find left view and right view of binary tree in java: This algorithm is an extension of breadth first search. In BFS we just print level wise nodes whereas here while printing level wise …

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

how to print leaf nodes in a binary search tree The logic here is simple. Recursively go through left and then right elements, when it goes beyond these two recursive calls, ..

types of traversals in a binary tree There are three types of traversals in binary tree: pre-order, in-order and post-order …


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Mostly technology with occasional sprinkling of other random thoughts


Amir Amintabar's personal page

101 Books

Reading my way through Time Magazine's 100 Greatest Novels since 1923 (plus Ulysses)

Seek, Plunnge and more...

My words, my world...

ARRM Foundation

Do not wait for leaders; do it alone, person to person - Mother Teresa

Executive Management

An unexamined life is not worth living – Socrates

Diabolical or Smart

Nitwit, Blubber, Oddment, Tweak !!


A topnotch site


Just another site

coding algorithms

"An approximate answer to the right problem is worth a good deal more than an exact answer to an approximate problem." -- John Tukey