CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

The number of substrings (of all lengths inclusive) that can be formed from a character string of length n is

A
n
No worries! Weā€˜ve got your back. Try BYJUā€˜S free classes today!
B
n2
No worries! Weā€˜ve got your back. Try BYJUā€˜S free classes today!
C
n(n1)2
No worries! Weā€˜ve got your back. Try BYJUā€˜S free classes today!
D
n(n+1)2
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
Open in App
Solution

The correct option is D n(n+1)2
For a string of length n:

The number of substrings of length 1= n

The number of substrings of length 2= n - 1

The number of substrings of length 3= n -2

and so on....
The number of substrings of length n is 1
So total number of substrings

= n+(n - 1) + ...+ 1
= Sum of n natural numbers
= n(n+1)2



flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon