Sunday, 5 November 2017

What are the difference between Tree and Graph Data Structure?

Below are some important difference between trees and graphs:

1. Tree is a hierarchical model structure and Graph is network model.

2. All trees are graphs But all graphs are not trees.

3. There must be a root node in tree and there is no such kind of root node in graphs.

4. Tree contains no loops, no circuits but Graph may contain self-loops, loops.

5. Tree must be connected but Graph may not be connected.

6. A tree is a special kind of graph that there is only one way to get from X to Y, but in a graph there are multiple paths to get from point X to point Y.

7. We do traversal on trees, but we do searching on graphs. 

8. If tree have “n” vertices then it must have maximum of  “n-1” edges, but in graphs number of edges doesn’t depend on the number of vertices.

9. Trees are used for sorting and traversing, but graphs are used for graph coloring and job scheduling.

10. Trees are less in complexity compared to graphs, but high complexity than trees due to loops.

11. Trees can be classified as Binary tree, Binary search tree, AVL trees, Heaps, but graphs are like directed graphs and undirected graphs.


Thanks 
Mukesh Rajput

No comments:

Post a Comment

Thanks
Mukesh Rajput