Open In App

UGC-NET | UGC NET CS 2018 Dec – II | Question 17

Like Article
Like
Save
Share
Report

The number of substrings that can be formed from string given by “a d e f b g h n m p” is
(A) 10
(B) 45
(C) 56
(D) 55


Answer: (C)

Explanation: Total number of non-empty substrings of all lengths from 1 to n

= n + (n-1) + (n-2) + (n-3) + … 2 + 1
= n * (n + 1)/2 

These are non-empty substrings, but if you count null substrings there are [n(n+1)/2] + 1.

Where, n = 10,
So, total number of all substrings are = 10*11/2 + 1 = 55+1 = 56.

Option (C) is correct.

Quiz of this Question


Last Updated : 02 Nov, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads