Count the number of possible sub-strings from a given string of length n.

Total number of sub strings present in  "GATE" is

A)7       B) 10          C) 11         D)  8 

 

Answer-11

explanation:

 

length = 1 ( null/epsilon)

1 length = 4 (G,A,T,E)

2 length=3 ( GA, AT , TE)

 

My doubt is->Here why are we not considering GT,GE and AE while counting strings of length 2?

3 length= 2 ( GAT, ATE)

 

My doubt is->Here why are we not considering GET and AGE while counting strings of length 3?

4 length = 1( GATE)

3Comments
Abhisek Panda @abhisek.panda
25 Aug 2017 07:49 pm

Ohk.. Listen, 

Substrings are consecutive subsequences.

Reference : https://math.stackexchange.com/questions/1237097/difference-subsequences...

Aditya Aishwary @adityaaishwary
25 Aug 2017 09:28 pm

Thx Mate. Appreciated !!

Rahul @rahul55523
25 Aug 2017 11:19 pm

direct  formula {n(n+1)/2}+1