Data Structures & AlgorithmsVery hardGATE CS · TCS NQT

How many proper borders (non-empty proper prefixes that are also suffixes) does "abaabaaba" have?

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

Correct answer: B. 3

Borders are found by the prefix-function chain from the end. Each border length corresponds to a repeated prefix at the suffix, and the chain includes all of them.

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

Exams that ask this topic