Data Structures & AlgorithmsModerateTCS NQT · GATE CS

A rod of length 17 must be cut into pieces each of length at most 5. What is the minimum number of cuts?

  1. A. 4
  2. B. 3
  3. C. 2
  4. D. 5

Correct answer: B. 3

Each cut adds one piece, and a rod needs ⌈a / L⌉ pieces at least, so cuts = ⌈a / L⌉ − 1. Cutting into exactly a/L pieces of length L uses floor-division and misses the remainder piece.

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

Exams that ask this topic