Data Structures & AlgorithmsHard

Why is the OR of a subarray always at least the maximum element of that subarray?

  1. A. OR is always smaller than the smallest element.
  2. B. OR equals the sum of the subarray.
  3. C. OR keeps every set bit of each operand, so the result is at least each operand, including the largest.
  4. D. OR depends only on the length.

Correct answer: C. OR keeps every set bit of each operand, so the result is at least each operand, including the largest.

Each operand's bits survive in the OR, so the result is never smaller than any single operand. The maximum is therefore a lower bound for the OR.

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

Exams that ask this topic