Binary Tree Data Structure
Learn more about Binary Tree in DSA Self Paced Course
Practice Problems on Binary Tree !
Recent Articles on Binary Tree !
Some Quizzes on Binary Tree
What is Binary Tree Data Structure?
Binary Tree is defined as a tree data structure where each node has at most 2 children. Since each element in a binary tree can have only 2 children, we typically name them the left and right child.
Binary Tree Representation
A Binary tree is represented by a pointer to the topmost node (commonly known as the “root”) of the tree. If the tree is empty, then the value of the root is NULL. Each node of a Binary Tree contains the following parts:
- Pointer to left child
- Pointer to right child
Basic Operation On Binary Tree:
- Inserting an element.
- Removing an element.
- Searching for an element.
- Traversing the tree.
Auxiliary Operation On Binary Tree:
- Finding the height of the tree
- Find the level of a node of the tree
- Finding the size of the entire tree.
Basic Operations on Binary Tree:
Some other important Binary Tree Traversals :
- Level order traversal in spiral form
- Reverse Level Order Traversal
- BFS vs DFS for Binary Tree
- Inorder Tree Traversal without Recursion
- Morris traversal for Preorder
- Iterative Preorder Traversal
- Iterative Postorder Traversal Using Two Stacks
- Diagonal Traversal of Binary Tree
- Boundary Traversal of binary tree
Must solve Standard Problems on Binary Tree Data Structure:
- Calculate depth of a full Binary tree from Preorder
- Construct a tree from Inorder and Level order traversals
- Check if a given Binary Tree is SumTree
- Check if two nodes are cousins in a Binary Tree
- Check if removing an edge can divide a Binary Tree in two halves
- Check whether a given binary tree is perfect or not
- Check if a Binary Tree contains duplicate subtrees of size 2 or more
- Check if two trees are Mirror
- Foldable Binary Trees
- Symmetric Tree (Mirror Image of itself)
- Write Code to Determine if Two Trees are Identical
- Subtree with given sum in a Binary Tree
- Succinct Encoding of Binary Tree
- Write a program to Calculate Size of a tree
- Diameter of a Binary Tree
- Get Level of a node in a Binary Tree
- Find all possible binary trees with given Inorder Traversal
- Populate Inorder Successor for all nodes
- Construct Complete Binary Tree from its Linked List Representation
- Minimum swap required to convert binary tree to binary search tree
- Convert a given Binary Tree to Doubly Linked List | Set 1
- Convert a tree to forest of even nodes
- Flip Binary Tree
- Print root to leaf paths without using recursion
- Check if given Preorder, Inorder and Postorder traversals are of same tree
- Check whether a given Binary Tree is Complete or not | Set 1 (Iterative Solution)
- Check if a binary tree is subtree of another binary tree | Set 2
- Find largest subtree sum in a tree
- Maximum sum of nodes in Binary tree such that no two are adjacent
- Lowest Common Ancestor in a Binary Tree | Set 1
- Height of a generic tree from parent array
- Find distance between two given keys of a Binary Tree
- Modify a binary tree to get Preorder traversal using right pointers only
- Construct Full Binary Tree using its Preorder traversal and Preorder traversal of its mirror tree
- Construct a special tree from given preorder traversal
- Construct tree from ancestor matrix
- Construct the full k-ary tree from its preorder traversal
- Construct Binary Tree from String with bracket representation
- Convert a Binary Tree into Doubly Linked List in spiral fashion
- Convert a Binary Tree to a Circular Doubly Link List
- Convert Ternary Expression to a Binary Tree
- Check if there is a root to leaf path with given sequence
- Remove all nodes which don’t lie in any path with sum>= k
- Maximum spiral sum in Binary Tree
- Sum of nodes at k-th level in a tree represented as string
- Sum of all the numbers that are formed from root to leaf paths
- Merge Two Binary Trees by doing Node Sum (Recursive and Iterative)
- Find root of the tree where children id sum for every node is given
If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write
comments if you find anything incorrect, or you want to share more information about the topic discussed above.