Tree data structure and its terminology


Why we need a tree data structure?


In the array, linked list, stack, and queue data is store in a sequential manner which is difficult to search specific data .the search becomes slow when a huge amount of data stored.


This is a very annoying thing in the fast world. All people want to get the result as soon as possible. Different Tree data structures allow to access the data quickly and also it is not a linear data structure.


First of all, look at the terminologies of the tree before understanding the concept of the tree.

What is a tree?

A collection of nodes that are connected by directed edges is known as tree. It is a nonlinear structure as compare to arrays, linked lists, and stacks.

Node:

A node is a struct that contains a value (data) and stores its pointer. There are two types of nodes internal nodes those nodes which contain at least one child leaf node and external nodes those nodes which are the last.


Edge:

This is a link between nodes.


Root:

It is the top most node of a tree.

Depth of the node:

The number of edges from the root to the node is known as the depth of the node.

Height of the tree:

The number of edges from the root node to the last leaf is called the height of the tree.

Forest:

The collection of disjoint trees is called a forest.

Degree of a Node:

The total number of branches of the node is known as the degree of the node.

Types of the tree:


1-Binary tree

2-Binary search tree

3-AVL tree

4-B-tree





Comments

Popular posts from this blog

how to cout in cpp

Flutter layout

input by cin in c++