What is the time complexity for searching an element in a graph?

2025

What is the time complexity for searching an element in a graph?

  1. A.

    O(1)

  2. B.

    O(n)

  3. C.

    O(log n)

  4. D.

    O(n^2)

Attempted by 183 students.

Show answer & explanation

Correct answer: B

The time complexity for searching an element in a graph is O(n), where 'n' is the number of vertices in the graph.

Explore the full course: Cocubes Preparation