The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
38 views
The number of substrings(of all lengths inclusive) that can be formed from character string of length n is

a)n

b)n^2

c)n(n-1)/2

d)(n(n+1)/2)+1
asked ago in Theory of Computation by (15 points) | 38 views
0
let's take an example:

s = ABC

length 0 = 1

lenght 1 = {A , B , C} = 3

length 2 = {AB , BC } = 2

length 3 = {ABC} = 1

total string = length 0 + length 1 + length 2 + length  3 = 1 + 3 + 2 + 1 = 7

option D is the correct answer
0
For length 2,why have u not considered AC?
0
@anji

AC is not  Substring of ABC   because it is separated by B , Substring is that in which we add another substring , in either left are Right side of Substring to get actual Substring.
0
0

Substring is defined as "Zero or more Consecutive symbols taken"

What you must be confusing it with is "Subsequence" which is defined as "Zero or more Symbols left out (Consecutive or Not)"


Subword is defined as "One or more Consecutive symbols taken" (Subword is same as substring except for Zero length string)

 

Please log in or register to answer this question.



Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

35,485 questions
42,741 answers
121,445 comments
42,135 users