Graphs


Points to remember:

  1. Breadth-first search is used to calculate the shortest path for  an unweighted graph. 
  2. Dijkstra’s algorithm is used to calculate the shortest path for  a weighted graph. 
  3. Dijkstra’s algorithm works when all the weights are positive. 
  4. If you have negative weights, use the Bellman-Ford algorithm.


Commonly Interview Questions:

1. Implement BFS and DFS.
2. Check if a graph is a tree or not.
3. Count number of edges in a graph.
4. Find the shortest path between two vertices.

No comments:

Post a Comment