Question DSA-GRAPH-0068
HardWhy does Prim's algorithm with an adjacency matrix and no heap take O(V²)?
- A.
It uses union–find
- B.
It sorts the edges
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Graphs question
Why does Prim's algorithm with an adjacency matrix and no heap take O(V²)?
It uses union–find
It sorts the edges
Sign up free to see the answer and a step-by-step explanation.
It runs Dijkstra V times
Each of V steps scans all V vertices for the cheapest edge