# Binary Tree Data Structure

**Learn more about Binary Tree in DSA Self Paced Course****Practice Problems on Binary Tree !****Recent Articles 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:

- Data
- 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.

**Topic :**

**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:**

**Easy**- 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

**Medium**- 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

**Hard**- 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

### GeeksforGeeks Courses:

1. Language Foundation Courses [C++ / JAVA / Python ]

Learn any programming language from scratch and understand all its fundamentals concepts for a strong programming foundation in the easiest possible manner with help of GeeksforGeeks Language Foundation Courses – Java Foundation | Python Foundation | C++ Foundation

2.Complete Interview Preparation

Get fulfilled all your interview preparation needs at a single place with theComplete Interview Preparation Coursethat provides you all the required stuff to prepare for any product-based, service-based, or start-up company at the most affordable prices.

3.DSA Self Paced

Start learning Data Structures and Algorithms to prepare for the interviews of top IT giants like Microsoft, Amazon, Adobe, etc. withDSA Self-Paced Coursewhere you will get to learn and master DSA from basic to advanced level and that too at your own pace and convenience.

4. Company Specific Courses – Amazon & Microsoft

Crack the interview of any product-based giant company by specifically preparing with the questions that these companies usually ask in their coding interview round.

Refer GeeksforGeeks Company Specific Courses: Amazon SDE Test Series, etc.

**Recommended:**

If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to review-team@geeksforgeeks.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.