Category: Binary Tree

Postorder Traversal of Binary Tree Using Stacks 0

Postorder Traversal of Binary Tree Using Stacks

“Postorder Traversal of Binary Tree Using Stacks” is an important binary tree traversal algorithm. Here, we are given a binary tree and our task is to write a program to traverse the given binary tree in postorder manner using stack data structure. We have already discussed recursive implementation of postorder traversal....

Preorder Traversal of Binary Tree Using Stack 0

Preorder Traversal of Binary Tree Using Stack

“Preorder Traversal of Binary Tree Using Stack” is an important traversal algorithm of tree data structure. Here, we are given a binary tree and our task is to traverse the given binary tree in preorder fashion using stack data structure. We have already discussed recursive implementation here. Now, the iterative...

Inorder Tree Traversal Using Stack 0

Inorder Tree Traversal Using Stack

“Inorder Tree Traversal Using Stack” is a binary tree traversal algorithm where we traverse the given tree in inorder fashion using stack data structure.  We have already discussed the recursive approach of the inorder traversal. Here, we implement the same algorithm using stack data structure. The steps required to implement...

Compute Height of Binary Tree 0

Compute Height of a Binary Tree

“Compute Height of a Binary Tree” is a very basic problem of Tree data structure. Here, we are given a Binary Tree and our task is to compute height of given binary tree. The height of the tree is defined as total number of nodes in a longest path from...

Right View of Binary Tree 0

Right View of Binary Tree

“Right View of Binary Tree” is a very popular interview problem based on Tree data structure, asked in many technical interviews. Here, we are given a binary tree and our task is to write a program to print the Right View of Binary Tree. “Right View of Binary Tree” is...

Left View of Binary Tree 0

Left View of Binary Tree

“Left View of Binary Tree” is a very popular interview problem based on Tree data structure, asked in many technical interviews. Here, we are given a binary tree and our task is to write a program to print the Left View of Binary Tree. “Left View of Binary Tree” is...

Level Order Tree Traversal 0

Level Order Tree Traversal

Level Order Tree Traversal or Breadth First Traversal is another type of tree traversal algorithm where we traverse all nodes of the binary tree level-by-level. In previous post, we have already discussed preorder, inorder and postorder tree traversals which are typical types of Depth First Traversals. Trees can be traversed...

Maximum Width of Binary Tree 0

Maximum Width of Binary Tree

“Maximum Width of Binary Tree” is a basic problem of Tree data structure. Here, we are given a binary tree and our task is to find maximum width of Binary Tree. Maximum Width of Binary Tree is defined as maximum number of nodes present at any level of Binary Tree....

Print Alternate Levels of a Binary Tree 0

Print Alternate Levels of a Binary Tree

“Print Alternate Levels of a Binary Tree” is a simple modification of level order tree traversal algorithm. Here, we are given a Binary Tree and our task is to write a program to print alternate levels of a Binary Tree. Again, we can solve this problem using previous discussed two...

Count Number of Nodes in a Binary Tree 0

Count Number of Nodes in a Binary Tree

“Count Number of Nodes in a Binary Tree” is again a very basic problem of tree data structure. Here, we are given a tree and our task is to count the number of nodes in a tree. There can be multiple methods to count the number of nodes in a...