1.

What is the time complexity for finding a Hamiltonian path for a graph having N vertices (using permutation)?(a) O(N!)(b) O(N! * N)(c) O(log N)(d) O(N)This question was addressed to me during an interview.My question is taken from Checksum, Complexity Classes & NP Complete Problems in section Checksum, Complexity Classes & NP Complete Problems of Data Structures & Algorithms II

Answer» RIGHT choice is (b) O(N! * N)

To explain: For a graph having N vertices TRAVERSE the PERMUTATIONS in N! iterations and it traverses the permutations to SEE if adjacent vertices are connected or not takes N iterations (i.e.) O(N! * N).


Discussion

No Comment Found

Related InterviewSolutions