Points to remember:
- Breadth-first search is used to calculate the shortest path for an unweighted graph.
- Dijkstra’s algorithm is used to calculate the shortest path for a weighted graph.
- Dijkstra’s algorithm works when all the weights are positive.
- 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