C++ Program to Print the Nodes at Odd Levels of a Tree

This is a C++ Program to print odd levels of the tree. There are basically two functions in this method. One is to print all nodes at a given level (printGivenLevel), and other is to print level order traversal of the tree (printLevelorder). printLevelorder makes use of printGivenLevel to print nodes at all levels one … Read more

advertisement

C++ Program to Create Expression Tree from Infix Expression

This is a C++ Program to construct an Expression tree for an Infix Expression. A binary expression tree is a specific application of a binary tree to evaluate certain expressions. Two common types of expressions that a binary expression tree can represent are algebraic[1] and boolean. These trees can represent expressions that contain both unary … Read more

advertisement

C++ Program to Create Expression Tree from Postfix Expression

This is a C++ Program to create an expression tree and print the various traversals using postfix expression. Here is source code of the C++ Program to Construct an Expression Tree for a Postfix Expression. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below. #include … Read more

advertisement

C++ Program to Count the Number of Nodes in Binary Tree

This is a C++ Program for counting number of nodes present in a tree using recursion. Problem Description Here in this problem we will be finding the total number of nodes present in a given tree using C++ Language. Expected Input and Output Case 1. Balanced Tree:When the weight is equal on both the sides … Read more

advertisement

C++ Program to Count Leaf Nodes in a Binary Search Tree

This is a C++ Program for counting the total number of leaf nodes present in a given Binary Search Tree. Problem Description We will be given a Binary Search Tree and we have to create a C++ program which counts the total number of leaf nodes present in it using recursion. A leaf node is … Read more

advertisement

C++ Program to Count All Internal Nodes in a Binary Search Tree

This is a C++ Program for counting the total number of internal nodes present in a given Binary Search Tree. Problem Description We will be given a Binary Search Tree and we have to create a C++ program which counts the total number of non-leaf nodes i.e. Internal Nodes present in it using recursion. An … Read more

advertisement

C++ Program to Perform Left and Right Rotation on AVL Tree

This is a C++ Program to perform Left Rotation in Binary Search Trees. In discrete mathematics, tree rotation is an operation on a binary tree that changes the structure without interfering with the order of the elements. A tree rotation moves one node up in the tree and one node down. It is used to … Read more

advertisement

C++ Program to Check if a Binary Tree is an AVL Tree or Not

This is a C++ Program to check if BST is AVL. An AVL tree is a self-balancing binary search tree. It was the first such data structure to be invented. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ … Read more

advertisement

C++ Program to Remove All nodes which don’t lie in Any Path with Sum >= K

This C++ Program demonstrates the Removal of All the nodes which don’t lie in any Path with Sum greater than or equal to K. Here is source code of the C++ Program to Remove All the nodes which don’t lie in any Path with Sum >= K. The C++ program is successfully compiled and run … Read more

advertisement

C++ Program to Check if Binary Tree is Subtree of Another Tree

This is a C++ Program to check whether tree is subtree of another tree. Given two binary trees, check if the first tree is subtree of the second one. A subtree of a tree T is a tree S consisting of a node in T and all of its descendants in T. The subtree corresponding … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.