Skip to main content

Overview of Binary Tree

⛳ Overview

Binary Tree is an important data structure, and it's widely used in BFS, DFS, DP, Back tracking, Divide and conquer algorithms.

📃 Analysis

tip

3 Tree Traversals

  • Inorder: Left, Root, Right
  • Preorder: Root, Left, Right
  • Postorder: Left, Right,Root

Examples:

Binary tree

Inorder: 4 2 5 6 3 7 1
Preorder: 1 2 4 5 3 6 7
PostOrder: 4 5 2 6 7 3 1

✏ Code Editor

1. Print the level of each node

Live Editor
Result
Loading...

2. Print the number of leafs of each node

Live Editor
Result
Loading...