
Learn core concepts, essential formulas, and attempt practice questions designed on the latest TCS NQT testing patterns.
Dijkstra's algorithm fails for which graph types?
Correct Answer: A) Graphs with negative edge weights
Step-by-step Solution: Dijkstra assumes paths only grow longer. Negative edges violate this, leading to incorrect distances.
Kruskal's algorithm selects edges in what order?
Correct Answer: A) Sorted ascending by weight
Step-by-step Solution: Kruskal's is a greedy algorithm. It sorts all edges by weight and inserts the smallest edges first (if they don't form cycles).
Use Prim's for dense graphs (many edges) and Kruskal's for sparse graphs.