In this post we will check “Striver’s Tree Series : Tree Data Structure”.

## What is a tree data structure?

There are two major types of data structures:

- Linear
- Non-Linear

Tree is a Non-linear data structure where as Arrays, LinkedList are linear data structures. What makes tree a non-linear data structure is, the information or data is not stored in a sequential fashion, same is for traversal or retrieval.

Unlike, in arrays, we know that elements are stored at contiguous memory locations, however, it is not the same with trees. The nodes in a tree can be stored at random memory locations and can be linked to each other using pointers to define the structure of the tree.

Contents

## Why is tree data structure important?

To understand why tree? Think about why we created other data structures. In order to do that, link every data structure to some real world entity and see where it fit’s well.

Will you use an array to store information of your family’s hierarchy? No right, what do you visualise this hierarchy as? I visualise it as a tree.

That is it, tree is used and important to store hierarchical data.

## Tree data structure in C, C++, Java, Python

However, no data-structure is bound by any programming language. You can choose any of the above popular programming language and implement all possible trees in it. But, we highly recommend to go with any one of C++, Java or Python. These are object oriented language with a good number of inbuilt library functions.

## Why Striver’s Tree Series?

This is sheet is prepared by Raj Vikramaditya A.K.A Striver, Candidate Master, 6*, who has bagged offers from **Google** Warsaw, **Facebook** London, **Media.net**(Directi). He has also interned at **Amazon** India. He is also one of the top educators at Unacademy and was at GeeksforGeeks as well.

More over, these simple set of questions in the Striver’s Tree Series contains all important concepts required to excel in the Tree Data Structure.

## Problems on Tree Data Structure:

- Inorder Traversal of Binary Tree
- Preorder Traversal of Binary Tree
- Post-order Traversal of Binary Tree
- Morris Preorder Traversal of a Binary Tree
- Morris Inorder Traversal of a Binary Tree
- Preorder, Inorder, and Postorder Traversal in one Traversal
- Right/Left View of Binary Tree
- Bottom View of Binary Tree
- Top View of Binary Tree
- Vertical Order Traversal of Binary Tree
- Root to Node Path in Binary Tree
- Maximum width of a Binary Tree
- Level order Traversal / Level order traversal in spiral form
- Height of a Binary Tree
- Diameter of Binary Tree
- Check if the Binary tree is height-balanced or not
- LCA in Binary Tree
- Check if two trees are identical or not
- Zig Zag Traversal of Binary Tree
- Boundary Traversal of Binary Tree
- Maximum path sum
- Construct Binary Tree from inorder and preorder
- Construct Binary Tree from Inorder and Postorder
- Symmetric Binary Tree
- Flatten Binary Tree to LinkedList
- Check if Binary Tree is the mirror of itself or not
- Check for Children Sum Property
- Populate Next Right pointers of Tree
- Search given Key in BST
- Construct BST from given keys
- Construct BST from preorder traversal
- Check is a BT is BST or not
- Find LCA of two nodes in BST
- Find the inorder predecessor/successor of a given Key in BST.
- Floor in a BST
- Ceil in a BST
- Find K-th smallest/largest element in BST
- Find a pair with a given sum in BST
- BST iterator
- Size of the largest BST in a Binary Tree
- Serialize and deserialize Binary Tree
- Binary Tree to Double Linked List

Also checkout the Striver’s SDE Sheet to clear interviews of Amazon, Microsoft, or any other top tech startup.