Tree Data Structure

Tree Data Structure

2022, Jul 31    

Introduction

Data structures such as list(Arrays), linked list, stack and queue are linear data structures that data is stored sequentially. In order to perform any operation in a linear data structure, the time complexity increases with the increase in the data size. However, it is not acceptable in real life where we live in data flood.

The different tree data structures allow quicker and easier access to the data as it is a non-linear data structure. In this part, I would like to introduce basic knowledge of a tree data structure.


Tree Definition

A tree is an abstract model and can be defined as a collection of entities called nodes linked together through edges in a hierarchical structure. They don’t have any cyclic relations and there is only one path to a particular node.

  • Root: the top (initial) node of the tree
  • Node: an entity that hold key-value, representing as circle shape usually
  • Edge: a connection of two nodes and a tree has N-1 edges (N = the number of nodes)
  • Parent: a node which is a predecessor of any node
  • Child: a node which is descendant of any node
  • Siblings: a group of nodes which have the same parent
  • Leaf (terminal) node: a node without children node
  • Level: it is defined as 1 + the number of edges between the node and the root
  • Height: the number of edges from its root to the furthest leaf
  • Depth: the number of edges from the node to the tree’s root
  • Sub-tree: a portion of a tree data structure that can be viewed as a complete tree in itself


End

Tree is not only a well known data structure that loved from all software engineer but also basic concept to understand as a software engineer. It will follow you forever in software industry. So, Please make sure you understand and keep it as your best friend.


reference

[Image-of-Data-Structure-Tree-Main/medium/article/byron]
[Definition-of-Data-Structure-Tree/programiz]
[General-definition-of-Data-Structure-Tree/wiki]