Data Structures & AlgorithmsVery hard

Which statement about the prefix product P_i and suffix product S_i modulo a prime p is correct when a zero element is present?

  1. A. If the array contains a zero, every product that includes it is zero mod p, so prefix or suffix products on one side collapse to zero.
  2. B. Zeros never affect modular products.
  3. C. Prefix products are always non-zero.
  4. D. Suffix products equal the total product divided by the prefix.

Correct answer: A. If the array contains a zero, every product that includes it is zero mod p, so prefix or suffix products on one side collapse to zero.

Any product containing a zero factor is zero, so the comparison of prefix and suffix products collapses for splits that include the zero. Division by prefix products is then impossible, which is why prefix and suffix arrays are used instead.

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

Exams that ask this topic