Difference Between Tree and Graph Data structure

In this tutorial you will learn about the Difference Between Tree and Graph Data structure and its application with practical example.

Difference Between Tree and Graph Data structure

What Is Tree Data Structure?

Trees are the most common and a kind of hierarchical data structure which stores data or information in sequential manner, and this all occurs because of a group of nodes which is basically a hierarchical bonding, it is a kind of non-linear data structure which works on the principle of parent-child relationship and each data item is noted as node and the top most node is called a parent node, and these nodes have their child nodes also. In data structure tree always grow downside, due to this characteristics searching and transverse can easily be done and insertion deletion and searching can be done real quick. Trees may be of following type, (1) General Tree, (2) Binary Tree, (3) Binary Search Tree, (4) AVL Tree, (5) B Tree.

What Is Graph Data Structure?

It is that kind of data structure, where the groups of nodes are present which is called as vertex and these vertices are so connected to each other in formation of bridge pattern and these patterns are called as edges. These edges works as a communication link between the two nodes. Graphs are a kind of non-primitive and non-linear data structure where the bunch of nodes vertices and edges are present and these may vary in directional as well as unidirectional way. Graphs are of following types (1) Directed graphs, (2) Undirected graphs, (3) Weighted graphs, (4) Non-weighted graphs.

Tree Vs Graph Data structure

TREES GRAPHS
Here elements are arranged at multiple levels due to is non-linear structure. It is also a kind of non-linear and non-primitive data structure.
Collection of nodes and edges are present. Collection of vertices and edges are present.
Edges and nodes are denoted as N,E respectively and written as T={N,E}. Edges and vertices are denoted as N,E respectively and written as T={V,E}.
The topmost node is representing as parent node and rest are their child nodes. There is no requirement of nodes.
Loop or cycle formation is not needed. Loop or cycle formation is needed.
It works on hierarchical model where nodes are arranged at multiple level. It works on network model and is used dynamically for SNS websites.
n-1 number of edges are present if there are nodes present in it as in directed edges. Dependencies of edges are present on the structure of graphs as in both directed & non-directed edges.
Operations like Insertion, deletion, searching can easily be done. It is used to find the shortest path for the network model.

In this tutorial we have learn about the Difference Between Tree and Graph Data structure and its application with practical example. I hope you will like this tutorial.