Q17: Time complexity to find independent set

Question #17: What is the time complexity of the following algorithm?

Here, a graph of n nodes is assumed and the problem is to find an independent set of size k. The algorithm enumerates all k sized subsets and then checks if any one of them satisfies the independent set property. Independent set is a set of vertices such that no two vertices in the set have an edge between them.

algo_ind_set

Options:

  1. O(nk)
  2. O(kn)
  3. O(nn)
  4. O(kk)

 

Solution:

There are C(n,k) total sets of size k from n vertices. And each of this set is checked, so complexity is of the order O(nk). Hence, the correct answer is option 1.