Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

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

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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

My Personal Notes arrow_drop_up
Last Updated : 02 Nov, 2021
Like Article
Save Article
Similar Reads