Consider the string “GATECSELECTURE” S1: “GATECSELECTURE” is a prefix of given…

Consider the string “GATECSELECTURE”

S1: “GATECSELECTURE” is a prefix of given string.

S2: “GATECSELECTURE” is a suffix of given string.

S3: “CSELECTURE” is a subsequence of given string.

S4: “GTCS” is a substring of given string.

Which of the above statement is/are FALSE?

Answer: B. Only S4A prefix of string s is any string obtained by removing zero or more symbols from the end of s. For example, GATE, GATECSE,GATECSELECTURE and ϵ are prefixes…

  1. A.

    Only S1 and S2

  2. B.

    Only S4

  3. C.

    Only S3 and S4

  4. D.

    Only S3

Attempted by 553 students.

Show answer & explanation

Correct answer: B

A prefix of string s is any string obtained by removing zero or more symbols from the end of s. For example, GATE, GATECSE,GATECSELECTURE and ϵ are prefixes of GATECSELECTURE.

A suffix of string s is any string obtained by removing zero or more symbols from the beginning of s. For example, LECTURE, CSELECTURE,GATECSELECTURE and ϵ are suffixes of GATECSELECTURE.

Evaluation of each statement:

  • S1 — "GATECSELECTURE is a prefix": True. The given string equals "GATECSELECTURE", and a string is a prefix of itself.

  • S2 — "GATECSELECTURE is a suffix": True. For the same reason as S1, the whole string is also a suffix of itself.

  • S3 — "CSELECTURE is a subsequence": True. Those characters appear in order and in fact contiguously at positions 5–14, so it is a subsequence (and a substring).

  • S4 — "GTCS is a substring": False. While the letters G, T, C, S appear in that order as a subsequence (positions 1, 3, 5, 6), they do not appear contiguously, so "GTCS" is not a substring.

Conclusion: Only the statement that "GTCS is a substring" is false. Therefore the correct answer is the choice that says only S4 is false.

Explore the full course: Isro

Loading lesson…