ProDeveloperTutorial.com

Tutorials and Programming Solutions
Menu
  • Shell Scripting
  • System Design
  • Linux System Programming
  • 4g LTE
  • Coding questions
  • C
  • C++
  • DSA
  • GIT
Check if Two Trees are Mirror Structure to each other

Check if Two Trees are Mirror Structure to each other

Question: Given a 2 binary trees root nodes, check if the structure is mirror to each other. Example: Consider the image given below and its mirror. If you can see in the above image, both the trees structure are mirror to each other. We don’t consider …
Full Article
No Comments
Get the count full nodes in a Binary

Get the count full nodes in a Binary

Problem statement: You are given root node of a tree and you need to find the number of full node in that tree. A node will be considered as full node if it has both left and right child. Consider the image below: Total number of …
Full Article
No Comments
Get count Non-Leaf nodes in a Binary Tree

Get count Non-Leaf nodes in a Binary Tree

Problem statement: You are given root node of a tree and you need to find the number of non leaf node in that tree. Consider the image below: Total number of non leaf node are 3. This problem can by solved by traversing the tree and …
Full Article
No Comments
Display all the leaf nodes from left to right and right to left in a tree

Display all the leaf nodes from left to right and right to left in a tree

Consider the below image You need to print the leaf node: Form left to right: 7, 15, 18, 30 Form right to left : 30, 18, 15, 7 Solution in C++ #include <iostream> #include <queue> #include <stack> using namespace std; // structure to hold binary tree …
Full Article
No Comments
Get depth of Odd level which contains Leaf node in Binary Tree

Get depth of Odd level which contains Leaf node in Binary Tree

The solution is very simple. We need to traverse the tree from root node. We need to keep track of the current level of the node. Increment the current level once you go left or right subtree. Return max depth of an odd level. Solution in …
Full Article
No Comments
Get deepest Left Leaf Node in Binary Tree

Get deepest Left Leaf Node in Binary Tree

Question: Given a binary tree root node, get the deepest left leaf node Example: Consider the image given below and its mirror. From the above image, node 7 is the deepest left leaf node. Solution in C++ #include <iostream> #include <queue> #include <stack> using namespace std; …
Full Article
No Comments
Get Vertical Sum of Binary Tree

Get Vertical Sum of Binary Tree

Problem Statement: You are given a root node, you need to calculate the vertical sum of the tree. Consider the image below Vertical-Line-1: has only one node 7 => vertical sum is 7 Vertical-Line-2: has only one node 10 => vertical sum is 10 Vertical-Line-3: has …
Full Article
No Comments
Check if two Binary Trees are Isomorphic

Check if two Binary Trees are Isomorphic

Question: Given a binary tree root node, check if the tree is a isomorphic tree. 2 trees are called isomorphic to each other, if they have same structure or mirror structure. And their data should also match. Solution in C++ #include <iostream> #include <queue> #include <stack> …
Full Article
No Comments
Check if Binary Tree is Foldable Tree

Check if Binary Tree is Foldable Tree

Question: Given a binary tree root node, check if the tree is a foldable tree. Example: Consider the image given below We can see that, the nodes of left and right Subtree are exact mirror of each other. So we can solve this problem by using …
Full Article
No Comments
Find Maximum or Minimum in Binary Tree

Find Maximum or Minimum in Binary Tree

Problem Statement: Given a binary tree root node, you need to find the minimum and maximum value of the nodes. Consider the image below: Minimum value is 7 and maximum value is 30. Solution: We can solve this problem by traversing the tree and checking the …
Full Article
No Comments

Posts navigation

1 2 3 4 … 56 Next
  • Shell Scripting
  • System Design
  • Linux System Programming
  • 4g LTE
  • Coding questions
  • C
  • C++
  • DSA
  • GIT

ProDeveloperTutorial.com

Tutorials and Programming Solutions
Copyright © 2021 ProDeveloperTutorial.com