Difference Between Tree and Graph

Computer ProgrammingProgrammingMiscellaneous

In this post, we will understand the difference between Tree and Graph.

Graph

  • It is a non-linear data structure.

  • It consists of vertices (also known as nodes) and edges.

  • A node can have any number of edges.

  • It doesn’t have a unique node like ‘root’.

  • A cycle could be formed.

  • Its application includes finding shortest path in a networking graph.

Tree

  • It is a non-linear data structure.

  • It consists of collection of nodes and edges.

  • A node can have any number of child nodes.

  • If it is a binary tree, it can have only two child nodes at maximum.

  • It consists of a node called the ‘root’ node.

  • It doesn’t form any cycle.

  • Its applications include game trees, decision trees.

raja
Published on 23-Mar-2021 08:13:43
Advertisements