Tree

Check binary tree is Quasi-Isomorphic of other tree in java (DFS / Example)

We are given two binary tree, we need to find out whether one binary tree is Quasi Isomorphic of other binary tree. Quasi Isomorphic tree? Trees are considered to Quasi isomorphic where we concerned about the structures. The structure of both tree either should be identical or obtained by swapping (or Mirror) its children.

Find InOrder predecessor in binary search tree (BST) in java (examples)

Predecessor of any node is the previous node of binary traversal. Let us take an example to understand the inorder predecessor in binary search tree. We have already discussed about the inorder successor. The logical flow of inorder predecessor and inorder successor is same. If we understand any one of them, other can be solved in similar manner.

Find maximum sum, root to leaf path in binary tree (Java/ recursive/ example)

Given the binary tree, There are multiple paths (equal to number of leaf nodes) exist from root to leaf nodes, We need to calculate the sum of all nodes in each root to leaf path, then we need to print the maximum sum and the corresponding path. Let us take the example to elaborate our problem statement.

Number of nodes or size of binary tree in java (DFS / examples)

Given the binary tree, we need to find number of nodes in the given binary tree. To count the number of nodes in binary tree, we need to visit all the nodes at least once. We have counted the number of nodes without recursion using level order traversal in this post.

Spiral or Zigzag binary tree traversal in java (BFS & example)

Breadth First Traversal or Level Order Traversal: As name suggests, in tree traversal, where in we are traversing the breadth of tree. In this traversal, we traverse all nodes across the breadth of binary tree. In level order traversal we perform following procedure:
Traverse the binary tree level by level
At each level we go left to right

Count non leaf nodes in binary tree in java (BFS /examples)

What is non leaf node in binary tree?
A node in a binary tree which has child node(s) is called non leaf node.
Non Leaf Node can be Node having one child or both children:
One child (Either left child or right child)
Two children (Both left child and right child)

Scroll to Top