Hint #1
Use DFS for this. Approach is the same as with BFS (refer to session 7 slides), except that you use DFS.Hint #0
This is classic dijkstra with no twist. Copy code from lecture slides lol.Hint #1
Do note that instead of being a vector > adj, where adj[i] -> vector of all neighbours to i, a weighted graph has vector > > adj, where adj[i] -> vector of pairs of {neighbour to i, weight of edge connecting i to neighbour}.Hint #0
Copy algo from slides lolHint #1
Do note that instead of being a vector > adj, where adj[i] -> vector of all neighbours to i, a weighted graph has vector > > adj, where adj[i] -> vector of pairs of {neighbour to i, weight of edge connecting i to neighbour}.Hint #2
Remember to resize dist and fill it all with INF properly.The statement was not clear! Note:
- An employee cannot be its own boss.
- The graph is one component