Trees
In our last episode, we learned about Maps data structure. In this episode, we are going to learn about the below things on the Tree Data Structure
1) What is Tree Data Structure?
2) Architecture and Characteristics?
3) Operation Types?
4) Types of Trees?
5) Run Time Complexity Summary?
6) Examples of Real Word Scenarios where Trees are used?
So, let's get started.
1) What is Tree Data Structure?
A tree is a non-linear data structure that stores data in elements called nodes, and these nodes are connected with links called edges.
2) Architecture and Characteristics?
Well, there are many types of trees based on the order of nodes, but in this article, we will talk about the generic tree terminology, architecture, and characteristics of trees by taking a binary search tree (Its a type of Tree which we learn later) as an example.
Firstly, the tree should be completely connected, which means if you're starting from the root, there should be some way to reach every node.
A) The first or top node is called the Root Node.
B) The lines that connect all these nodes are called Edges or links, and the group of edges or links taken together is called a path.
C) Any node that has children is called a Parent Node or Internal Node.
D) Any node that doesn't have children is called Leaf Node or External Node.
E) A node can have only one parent; nodes with the same parent are called siblings.
F) The node's Height is the number of edges between it and the furthest leaf of the tree. The Height of the leaf is zero, and the Height of the parent of the leaf is one, the Height of the tree overall is the Height of the root node. The depth of the node is the number of edges between it and the root. Depth and Height are inversely proportional to each other.
G) The tree hierarchy can be expressed in Levels; the root node is at Level 0.
H) The child to the root node is at Level 1.
I) The leaf node is at Level 2, and so on and so forth.
Recommended by LinkedIn
3) Operation Types?
3.1) Traversal Operations: - There are two different broad approaches called Breadth-first Search and Depth First Search, also known as BFS and DFS, respectively.
Based on How you traverse the tree? DFS can be classified into 3 types, i.e., Pre-order, In-order, and post-order; let's have a quick look at them below.
A) Pre-order
B) In-order
C) Post-order,
3.2) Insert, Update, Delete
4) Types of Trees?
Based on the order of nodes, Trees can be divided into many types, but in this article, we will throw light on the most discussed Tree types in the computer science fraternity.
5) Run Time Complexity Summary?
6) Examples of Real Word Scenarios where are Trees?
I would like to conclude episode eight of our Season 2 here; stay tuned for episode 9.
References
Disclaimer
This article is governed by the "Fair Use" doctrine and is only for purposes such as criticism, comment & teaching.
Note: - This is a live article.