Tree Basics | Part 1

By Prajwal Haniya

Techletter #28 | May 22, 2023

What are trees?

A tree is a non-linear data structure. A tree can be empty with no nodes or a tree is a structure consisting of one node called the root and zero, one or more subtrees.

Two important properties of a tree are:

Some of the must-know terms

What is a binary tree?

A binary tree is a type of tree in which each node can have at most two child nodes, known as the left child and the right child.

        A
       / \
      B   C
     / \   \
    D   E   F

There are different types of binary trees:

What is the difference between a binary tree and a binary search tree?

In a binary tree, each node can have at most two child nodes: a left child and a right child. The ordering of nodes in a binary tree is not based on any specific criteria or property. Whereas in a Binary Search Tree: the left child will always be less than the parent node and the right child is always greater than the parent node.

// Binary tree
        A
       / \
      B   C
     / \   \
    D   E   F

// Binary Search Tree
        5
       / \
      3   8
     / \   \
    2   4   9

There are different tree traversal techniques:

In the upcoming articles lets go through concepts like:

Implementation of Binary Tree, Binary Search Tree, Balanced Binary Tree, Tree traversal, Trie, & Heap.