Data Structures & AlgorithmsModerateGATE CS · CAT · MBA placement

In how many ways can you choose 3 indices from the 9 positions 1 to 9 so that no two chosen positions are adjacent (consecutive integers)?

  1. A. 84
  2. B. 35
  3. C. 41
  4. D. 36

Correct answer: B. 35

Pick k non-adjacent positions from n by placing the chosen ones into n − k + 1 gaps: the count is C(n − k + 1, k). Choosing any 3 positions out of 9 without the adjacency rule gives C(9, 3).

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic