Open In App

Tree Data Structure

Last Updated : 06 Jul, 2025
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

Tree Data Structure is a non-linear data structure in which a collection of elements known as nodes are connected to each other via edges such that there exists exactly one path between any two nodes.

root

Types of Tree

  • Binary Tree : Every node has at most two children
  • Ternary Tree : Every node has at most three children
  • N-ary Tree : Every node has at most n children.
tree

Applications of Tree

1. Height of a Node

The height of a node is the number of edges on the longest path from that node to a leaf. Leaf nodes have height 0.

height_of_a_tree

2. Depth of a Node

The depth of a node is the number of edges from the root to that node. The root node has depth 0.

depth_of_a_node

Basics of Tree Data Structure

Binary Tree

  1. Binary Tree Guide
  2. Applications of Binary Tree
  3. Properties of Binary Tree
  4. Tyes of Binary Tree
  5. Inorder Traversal
  6. Preorder Traversal
  7. Postorder Traversal
  8. Level Order Tree Traversal
  9. Height or Depth
  10. Level of a Given Node in Tree
  11. Search a Node
  12. Find the Parent
  13. Insertion
  14. Deletion
  15. Enumeration of Binary Trees
  16. Find all Leaf nodes
  17. Array Implementation

Binary Search Tree

  1. Binary Search Tree Guide
  2. Applications
  3. Searching
  4. Insertion
  5. Traversals – Inorder, Preorder, Post Order
  6. Deletion
  7. More Problems on Binary Search Tree

AVL Tree

  1. AVL Tree Data Structure
  2. Insertion
  3. Deletion
  4. Weak AVL or Rank Balanced Trees
  5. AVL with duplicate keys
  6. Count greater nodes in AVL tree
  7. How to insert Strings into an AVL Tree
  8. Minimum nodes in an AVL Tree with given height
  9. Optimal sequence for AVL tree insertion
  10. Different shapes of AVL possible at height h

Red-Black Tree

  1. Introduction to Red-Black Tree
  2. Insertion in Red-Black Tree
  3. Red-Black Trees | Top-Down Insertion
  4. Deletion in Red-Black Tree
  5. Applications, Advantages, and Disadvantages of Red-Black Tree

Ternary Search Tree

  1. Ternary Search Tree
  2. Ternary Search Tree meaning & definition in DSA
  3. Ternary Search Tree (Deletion)
  4. How to implement text Auto-complete feature using Ternary Search Tree
  5. Longest word in ternary search tree

n-ary or Generic Tree

  1. Generic Trees(N-ary Trees)
  2. What is Generic Tree or N-ary Tree
  3. Depth of an N-ary Tree
  4. Children of a Node in an N-ary Tree
  5. Find Siblings in an N-ary Tree
  6. Mirror of n-ary Tree
  7. Diameter of an N-ary Tree
  8. Level Order Traversal of N-ary Tree
  9. Sum of all elements of N-ary Tree
  10. Serialize and Deserialize an N-ary Tree

B Tree

  1. Introduction of B-Tree
  2. What is B-Tree? | B-Tree meaning
  3. Insert Operation in B-Tree
  4. Delete Operation in B-Tree
  5. B-Tree Insert without aggressive splitting

B+ Tree

  1. Introduction of B+ Tree
  2. What is B+ Tree | B+ Tree meaning
  3. Insertion in a B+ tree
  4. Deletion in B+ Tree

Other types of Trees

Trees vs other Data Structures

  1. Difference between graph and tree
  2. Comparison between Heap and Tree
  3. What is the difference between Heap and Red-Black Tree?
  4. Difference between Binary Search Tree and Binary Heap
  5. Difference between Stack and Tree
  6. Difference between an array and a tree

Comparison among different Tree Data Structures

  1. Difference between General tree and Binary tree
  2. Difference between Binary Tree and Binary Search Tree
  3. Difference between Binary tree and B-tree
  4. Difference between B tree and B+ tree
  5. Difference between Full and Complete Binary Tree
  6. Difference between Binary Search Tree and AVL Tree
  7. Red Black Tree vs AVL Tree

Problems based on Tree Data Structure

Problems

Difficulty Level

Solve

Height of Binary Tree

Easy

Solve
Determine if two trees are identical

Easy

Solve
Mirror tree

Easy

Solve
Symmetric Tree

Easy

Solve
Diameter of tree

Easy

Solve
Checked for Balanced tree

Easy

Solve
Children Sum Parent

Easy

Solve
Check for BST

Easy

Solve
Array to BST

Easy

Solve
Largest value in each level of binary tree

Easy

Solve
Maximum GCD of siblings of a binary tree

Easy

Solve
Zigzag Tree Traversal

Easy

Solve
Inorder Successor in BST

Easy

Solve
Kth Largest Element in a BST

Easy

Solve
Check if subtree

Medium

Solve
Single Valued Subtree

Medium

Solve
Unique BSTs

Medium

Solve
Inorder Traversal (iterative)

Medium

Solve
Preorder Traversal (iterative)

Medium

Solve
Postorder Traversal(iterative)

Medium

Solve
Vertical Traversal of a Binary Tree

Medium

Solve
Boundary Traversal

Medium

Solve
Construct Binary Tree from Parent array

Medium

Solve
Construct Binary Tree from Preorder and Inorder Traversal

Medium

Solve
Preorder Traversal and BST

Medium

Solve
Construct tree from preorder traversal

Medium

Solve
Minimum distance between two given nodes

Medium

Solve
Maximum sum leaf to root path

Medium

Solve
Odd Even Level Difference

Medium

Solve
Lowest Common Ancestor of a Binary Tree

Medium

Solve
Ancestors in Binary Tree

Medium

Solve
Remove BST keys outside the given range

Medium

Solve
Pair with given target in BST

Medium

Solve
Sum Tree

Medium

Solve
BST to greater sum tree

Medium

Solve
BST to max heap

Medium

Solve
Clone binary tree with random pointer

Medium

Solve
Maximum sum of non adjacent nodes

Medium

Solve
Largest BST in a Binary Tree

Medium

Solve
Extreme nodes in alternate order

Medium

Solve
Connect nodes at same level

Hard

Solve
Nodes at given distance in a Binary Tree

Hard

Solve
Sorted Linked List to BST

Hard

Solve
Binary Tree to Doubly Linked List

Hard

Solve
Maximum sum path between two leaf nodes

Hard

Solve
K-Sum Paths

Hard

Solve
Number of turns in a binary tree

Hard

Solve
Merge two BST’s

Hard

Solve
Fixing two nodes of a BST

Hard

Solve
Burn Binary Tree

Hard

Solve

Quick Links:


Next Article
Article Tags :
Practice Tags :

Similar Reads