Blogs Hub

by AskGif | Aug 16, 2018 | Category :coding

Search an element in binary tree without recursion.

Search an element in binary tree without recursion.

We can use level order traversal for solving this problem. The only change required in level order traversal is, instead of printing the date we just need to check whether the root data is equal to the element we want to search. source: Data Structures and Algorithms Made Easy in Jav

read more...

by AskGif | Aug 16, 2018 | Category :coding

Find maximum element in binary tree without recursion.

Find maximum element in binary tree without recursion.

We could have used either PreOrder, InOrder or PostOrder traversal to find the maximum in a Tree but as it is mentioned that we need to find the maximum without using Recursion. Using Level Order Traversal we can find the Maximum element. We just need to observe the elements data while de

read more...

by AskGif | Aug 14, 2018 | Category :coding

How to implement Level Order Traversal in Binary Tree?

How to implement Level Order Traversal in Binary Tree?

Trees can also be traversed in level-order, where we visit every node on a level before going to a lower level. This search is referred to as a breadth-first search (BFS), as the search tree is broadened as much as possible on each depth before going to the next depth. Java implementation

read more...

by AskGif | Aug 09, 2018 | Category :coding

How to implement PostOrder Traversal in Binary Tree?

How to implement PostOrder Traversal in Binary Tree?

PostOrder Traversal is different from InOrder Traversal and PreOrder Traversal. In this Traversal approach we first traverse through left and then right and at the end, we traverse to the node data. In PostOrder traversal, the root is visited after both subtrees. PostOrder traversal is de

read more...

by AskGif | Aug 09, 2018 | Category :coding

How to implement InOrder Traversal in Binary Tree?

How to implement InOrder Traversal in Binary Tree?

The Technique for traversal in an Inorder is slightly different from what we were doing in PreOrder Traversal. Here we go through left node, then data and then the right node. In an InOrder traversal, the root is visited between the subtrees. InOrder traversal is defined as follows:

read more...

by AskGif | Aug 09, 2018 | Category :coding

How to implement PreOrder Traversal in Binary Tree?

How to implement PreOrder Traversal in Binary Tree?

In pre-order traversal, each node is processed before (pre) either of it's sub-trees. This is the simplest traversal to understand. However, even though each node is processed before the subtrees, it still requires that some information must be maintained while moving down the tree. Preor

read more...