Multiple choice

The time required by Prim's algorithm is ______.

  1. O(|V|2)

  2. O(VlogE)

  3. O(EV)

  4. O(log V)

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Prim's algorithm on an adjacency matrix requires scanning all vertices to find the minimum weight edge, taking O(|V|) per vertex. With |V| iterations, total is O(|V|²). With Fibonacci heap + adjacency list, it becomes O(|E| + |V| log |V|), but O(|V|²) is the standard answer for basic implementation.