ProDeveloperTutorial.com

Tutorials and Programming Solutions
Menu
  • Shell Scripting
  • System Design
  • Linux System Programming
  • 4g LTE
  • Coding questions
  • C
  • C++
  • DSA
  • GIT

Author: prodevelopertutorial

Daily we discuss about competitive programming questions, join us at:   Telegram Channel

Get Sum of all Leaf Nodes in Binary Tree

Get Sum of all Leaf Nodes in Binary Tree

Problem Statement: Given a binary tree root node, you need to find the sum of all the leaf nodes. Consider the image below: The leaf nodes are 7, 15, 18, 30. So the sum is 70. We can solve this problem by checking if the node …
Full Article
No Comments

Get Average of all nodes in Binary Tree

Question: Given a binary tree root node, get the average of all nodes in Binary Tree Solution: The sum of all the nodes is 121 Total number of nodes are :7 So the average is 121/7 = 17.2   Solution in C++ #include <iostream> #include <queue> …
Full Article
No Comments
Get Sum of all nodes formed from Root to Leaf Path

Get Sum of all nodes formed from Root to Leaf Path

Question:  Given a binary tree root node, get the sum of the values of all the nodes formed from root to the leaf node. Solution: From the above image, we have 4 leaf nodes i.e : 3, 4, 6, 7 So the paths will be 1 …
Full Article
No Comments
Check if given two nodes are siblings to each other in Binary Tree

Check if given two nodes are siblings to each other in Binary Tree

Question: Given a binary tree root node and 2 node value, check if those 2 nodes are siblings. Solution: If we send the node value as 7 and 15, they are siblings If we send the node value as 7 and 18 they are not siblings. …
Full Article
No Comments
Find Sibling node of a given node value in Binary Tree

Find Sibling node of a given node value in Binary Tree

Question: Given a binary tree root node and a node value, get the sibling of that node. Solution: If the input node value is 10, its sibling is 25 If the input node value is 7, its sibling is 15 If the input node value is …
Full Article
No Comments
Check if given Binary Tree is BST

Check if given Binary Tree is BST

Question: Given a binary tree root node, check if it is a Binary Search Tree Solution: A Binary Tree is a BST if it satisfy below 2 conditions. The node values left of the root node should always be less and The node values right of …
Full Article
No Comments
Find Parent of a given node value in Binary Tree

Find Parent of a given node value in Binary Tree

Question: Given a binary tree node and root node, get the parent node of that node. Solution: Solution is very simple. Before we go to the child node of any parent node, we check if the children nodes is equal to given value. If it is …
Full Article
No Comments
Check if all Leaf Nodes are at same level in Binary tree

Check if all Leaf Nodes are at same level in Binary tree

Question: Given a binary tree root node, check if all Leaf Nodes are at same level in Binary tree Solution: We can solve this question with the help of pre-order traversal. First we visit the left leaf and update the level value, and then check with …
Full Article
No Comments
Check if binary tree is a height balanced tree?

Check if binary tree is a height balanced tree?

Question: Given a binary tree root node, check if the tree is a height balanced tree. What is a height balanced tree? A tree is called as height balanced tree if the difference between left height and right height should not be more than 1. It …
Full Article
No Comments
Display elements between any two given level

Display elements between any two given level

Question: Given a binary tree root node and 2 level, print the nodes between those levels. Example: Consider the image given below If given level is 2 and 3 the nodes that should be printed are: 10, 25, 7, 15, 18, 30 Solution: We do this …
Full Article
No Comments

Posts navigation

Prev 1 2 3 4 5 … 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
Get top courses from: Educative.io