DataStructures / Data structures Interview questions
Difference between a Tree and Graph in Data structure.
Tree. | Graph. |
Tree is a special form of graph also called as minimally connected graph having only one path between any two vertices. | A graph vertices can have more than one path, that is, a graph can have uni-directional or bi-directional paths (edges) between nodes. |
A tree has no loops, no circuits and no self-loops. | Graph can have loops, circuits and also self-loops. |
There is only one root node and every child have only one parent. | In graph there is no such concept of root node. |
In trees, there is parent child relationship between nodes. | In Graph there is no such parent child relationship. |
Trees are less complex in nature then graphs. | Graphs are more complex than trees as it can have cycles, loops. |
Types of trees are: Binary Tree , Binary Search Tree, AVL tree, Heaps. | Two types of Graphs are Directed and Undirected graph. |
Tree always has n-1 edges. | In Graph, number of edges depends on the graph. |
Tree is a hierarchical model. | Graph is a network model. |
Tree is traversed in Pre-Order, In-Order and Post-Order. | Graph is traversed by DFS: Depth First Search and in BFS : Breadth First Search algorithm. |
Dogecoin
! Earn free bitcoins up to $250 now by signing up.
Earn bitcoins upto $250 (free), invest in other Cryptocurrencies when you signup with blockfi.
Use the referral link: Signup now and earn!
Using BlockFi, don't just buy crypto - start earning on it. Open an interest account with up to 8.6% APY, trade currencies, or borrow money without selling your assets.
Join CoinBase
! We'll both receive $10 in free Bitcoin when they buy or sell their first $100 on Coinbase! Available in India also.
Use the referral Join coinbase!
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull
! Receive free stock by signing up using the link: Webull signup.
More Related questions...