Data Structures & AlgorithmsModerateTCS NQT · graph theory

Problem: Which is the time complexity of deciding whether an undirected graph has an Euler path?

  1. A. O(V^3)
  2. B. O(E^2)
  3. C. O(2^V)
  4. D. O(V + E)

Correct answer: D. O(V + E)

An Euler path exists iff the graph is connected (apart from isolated vertices) and has 0 or 2 odd-degree vertices, which takes linear time to check.

More Coding Interview Problems questions

Exams that ask this topic