Striver’s Tree Series : Tree Data Structure

Striver’s Tree Series

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.

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:

Problem/SolutionLeetcodeYoutube
Introduction to Trees Link
Binary Tree Representation in C++ Link
Binary Tree Representation in Java Link
Binary Tree Traversals in Binary Tree  Link
Preorder Traversal of Binary Tree Link Link
Inorder Traversal of Binary Tree Link Link
Post-order Traversal of Binary Tree Link Link
Level order Traversal / Level order traversal in spiral form Link Link
Iterative Preorder Traversal of Binary Tree Link Link
Iterative Inorder Traversal of Binary Tree Link Link
Post-order Traversal of Binary Tree using 2 stack Link Link
Post-order Traversal of Binary Tree using 1 stack Link Link
Preorder, Inorder, and Postorder Traversal in one Traversal Link Link
Height of a Binary Tree Link Link
Check if the Binary tree is height-balanced or not Link Link
Diameter of Binary Tree Link Link
Maximum path sum Link Link
Check if two trees are identical or not Link Link
Zig Zag Traversal of Binary Tree Link Link
Boundary Traversal of Binary Tree Link Link
Vertical Order Traversal of Binary Tree Link Link
Top View of Binary Tree Link Link
Bottom View of Binary Tree Link Link
Right/Left View of Binary Tree Link Link
Symmetric Binary Tree Link Link
Root to Node Path in Binary Tree Link Link
LCA in Binary Tree Link Link
Maximum width of a Binary Tree Link Link
Check for Children Sum Property Link Link
Print all the Nodes at a distance of K in a Binary Tree Link Link
Minimum time taken to BURN the Binary Tree from a Node Link Link
Count total Nodes in a COMPLETE Binary Tree Link Link
 Requirements needed to construct a Unique Binary Tree | Theory Link Link
Construct Binary Tree from inorder and preorder Link Link
Construct the Binary Tree from Postorder and Inorder Traversal Link Link
Serialize and deserialize Binary Tree Link Link
Morris Preorder Traversal of a Binary Tree
Morris Inorder Traversal of a Binary Tree
Link Link
Flatten Binary Tree to LinkedList  Link Link
Introduction to Binary Search Tree Link Link
Search in a Binary Search Tree Link Link
Ceil in a Binary Search Tree Link Link
Floor in a Binary Search Tree Link Link
Insert a given Node in Binary Search Tree Link Link
Delete a Node in Binary Search Tree Link Link
Find K-th smallest/largest element in BST Link Link
Check if a tree is a BST or BT Link Link
LCA in Binary Search Tree Link Link
Construct a BST from a preorder traversal Link Link
Inorder Successor/Predecessor in BST Link Link
Binary Search Tree Iterator Link Link
Two Sum In BST | Check if there exists a pair with Sum K Link Link
Recover BST | Correct BST with two nodes swapped Link Link
Largest BST in Binary Tree Link Link

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