The number of substrings that can be formed from string given by \(a \: d \: e…

2018

The number of substrings that can be formed from string given by

\(a \: d \: e \: f \: b \: g \: h \: n \: m \: p\)

is

  1. A.

    10

  2. B.

    45

  3. C.

    55

  4. D.

    56

Attempted by 559 students.

Show answer & explanation

Correct answer: D

Count the characters in the string: a, d, e, f, b, g, h, n, m, p — there are 10 characters.

Formula for non-empty substrings: For a string of length n, the number of non-empty substrings is n(n+1)/2. This comes from summing the number of substrings of each length: for length k there are (n−k+1) substrings, so sum k=1 to n of (n−k+1) = n(n+1)/2.

  • Apply the formula with n = 10:

    10 × 11 / 2 = 55 non-empty substrings.

  • If the empty substring is also counted, add 1:

    55 + 1 = 56 total substrings including the empty substring.

Conclusion: The number of non-empty substrings is 55. If the problem explicitly includes the empty substring, the total becomes 56. The provided answer of 56 assumes the empty substring is included; if the intended interpretation is non-empty substrings, the correct value is 55.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor