Is there a mathematical way to know exactly how many substrings , prefixes , suffixes does a string have. for example w=âabbccâ
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
My trials were for prefixes and suffixes including the empty string for "abbcc" were equal to the (length_of_the_string + 1) but I couldn't figure out a way for calculating the number of substrings .
combinatorics discrete-mathematics
add a comment |Â
up vote
0
down vote
favorite
My trials were for prefixes and suffixes including the empty string for "abbcc" were equal to the (length_of_the_string + 1) but I couldn't figure out a way for calculating the number of substrings .
combinatorics discrete-mathematics
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
My trials were for prefixes and suffixes including the empty string for "abbcc" were equal to the (length_of_the_string + 1) but I couldn't figure out a way for calculating the number of substrings .
combinatorics discrete-mathematics
My trials were for prefixes and suffixes including the empty string for "abbcc" were equal to the (length_of_the_string + 1) but I couldn't figure out a way for calculating the number of substrings .
combinatorics discrete-mathematics
asked Oct 30 '14 at 17:14
Beeee
1
1
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
Do you mean how many distinct substrings or do you allow duplicates? If you wish to count distinct substrings, the answer depends on the particular string. I will address the latter question, the number of substrings allowing duplicates.
A substring is defined by a start index and an end index. Let the start index be the index of the first character in the substring and the end index be the index of the first character after the end of the string. Index characters starting at 1 (so the first character has index 1).
If a string has length $n$, there are $n+1$ possible start indices ranging from 1 to $n+1$ where $n+1$ means the substring starts after the end of the string (and thus must be empty). Given a start index $s$, there are $n+2-s$ possible end indices ranging from $s$ to $n+1$, meaning $n+2-s$ substrings starting at index $s$. You must sum this quantity over all possible choices of $s$:
$$sum_s=1^n+1n+2-s = (n+1)(n+2) - frac(n+1)(n+2)2 = frac(n+1)(n+2)2.$$
no I don't allow duplicates when I calculated it by writing down all the possibilities they were 14 for "abbcc" which are epislon, a, b, c, ab, abb, abbc, abbcc, bb, bbc, bbcc, bc, bcc, cc
â Beeee
Oct 30 '14 at 17:31
If you don't allow duplicates then my answer gives the maximum possible number of substrings and the minimum possible number is $n+1$, which occurs on the string consisting of one character repeating $n$ times.
â Solomonoff's Secret
Oct 30 '14 at 17:37
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Do you mean how many distinct substrings or do you allow duplicates? If you wish to count distinct substrings, the answer depends on the particular string. I will address the latter question, the number of substrings allowing duplicates.
A substring is defined by a start index and an end index. Let the start index be the index of the first character in the substring and the end index be the index of the first character after the end of the string. Index characters starting at 1 (so the first character has index 1).
If a string has length $n$, there are $n+1$ possible start indices ranging from 1 to $n+1$ where $n+1$ means the substring starts after the end of the string (and thus must be empty). Given a start index $s$, there are $n+2-s$ possible end indices ranging from $s$ to $n+1$, meaning $n+2-s$ substrings starting at index $s$. You must sum this quantity over all possible choices of $s$:
$$sum_s=1^n+1n+2-s = (n+1)(n+2) - frac(n+1)(n+2)2 = frac(n+1)(n+2)2.$$
no I don't allow duplicates when I calculated it by writing down all the possibilities they were 14 for "abbcc" which are epislon, a, b, c, ab, abb, abbc, abbcc, bb, bbc, bbcc, bc, bcc, cc
â Beeee
Oct 30 '14 at 17:31
If you don't allow duplicates then my answer gives the maximum possible number of substrings and the minimum possible number is $n+1$, which occurs on the string consisting of one character repeating $n$ times.
â Solomonoff's Secret
Oct 30 '14 at 17:37
add a comment |Â
up vote
0
down vote
Do you mean how many distinct substrings or do you allow duplicates? If you wish to count distinct substrings, the answer depends on the particular string. I will address the latter question, the number of substrings allowing duplicates.
A substring is defined by a start index and an end index. Let the start index be the index of the first character in the substring and the end index be the index of the first character after the end of the string. Index characters starting at 1 (so the first character has index 1).
If a string has length $n$, there are $n+1$ possible start indices ranging from 1 to $n+1$ where $n+1$ means the substring starts after the end of the string (and thus must be empty). Given a start index $s$, there are $n+2-s$ possible end indices ranging from $s$ to $n+1$, meaning $n+2-s$ substrings starting at index $s$. You must sum this quantity over all possible choices of $s$:
$$sum_s=1^n+1n+2-s = (n+1)(n+2) - frac(n+1)(n+2)2 = frac(n+1)(n+2)2.$$
no I don't allow duplicates when I calculated it by writing down all the possibilities they were 14 for "abbcc" which are epislon, a, b, c, ab, abb, abbc, abbcc, bb, bbc, bbcc, bc, bcc, cc
â Beeee
Oct 30 '14 at 17:31
If you don't allow duplicates then my answer gives the maximum possible number of substrings and the minimum possible number is $n+1$, which occurs on the string consisting of one character repeating $n$ times.
â Solomonoff's Secret
Oct 30 '14 at 17:37
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Do you mean how many distinct substrings or do you allow duplicates? If you wish to count distinct substrings, the answer depends on the particular string. I will address the latter question, the number of substrings allowing duplicates.
A substring is defined by a start index and an end index. Let the start index be the index of the first character in the substring and the end index be the index of the first character after the end of the string. Index characters starting at 1 (so the first character has index 1).
If a string has length $n$, there are $n+1$ possible start indices ranging from 1 to $n+1$ where $n+1$ means the substring starts after the end of the string (and thus must be empty). Given a start index $s$, there are $n+2-s$ possible end indices ranging from $s$ to $n+1$, meaning $n+2-s$ substrings starting at index $s$. You must sum this quantity over all possible choices of $s$:
$$sum_s=1^n+1n+2-s = (n+1)(n+2) - frac(n+1)(n+2)2 = frac(n+1)(n+2)2.$$
Do you mean how many distinct substrings or do you allow duplicates? If you wish to count distinct substrings, the answer depends on the particular string. I will address the latter question, the number of substrings allowing duplicates.
A substring is defined by a start index and an end index. Let the start index be the index of the first character in the substring and the end index be the index of the first character after the end of the string. Index characters starting at 1 (so the first character has index 1).
If a string has length $n$, there are $n+1$ possible start indices ranging from 1 to $n+1$ where $n+1$ means the substring starts after the end of the string (and thus must be empty). Given a start index $s$, there are $n+2-s$ possible end indices ranging from $s$ to $n+1$, meaning $n+2-s$ substrings starting at index $s$. You must sum this quantity over all possible choices of $s$:
$$sum_s=1^n+1n+2-s = (n+1)(n+2) - frac(n+1)(n+2)2 = frac(n+1)(n+2)2.$$
answered Oct 30 '14 at 17:22
Solomonoff's Secret
3,53811232
3,53811232
no I don't allow duplicates when I calculated it by writing down all the possibilities they were 14 for "abbcc" which are epislon, a, b, c, ab, abb, abbc, abbcc, bb, bbc, bbcc, bc, bcc, cc
â Beeee
Oct 30 '14 at 17:31
If you don't allow duplicates then my answer gives the maximum possible number of substrings and the minimum possible number is $n+1$, which occurs on the string consisting of one character repeating $n$ times.
â Solomonoff's Secret
Oct 30 '14 at 17:37
add a comment |Â
no I don't allow duplicates when I calculated it by writing down all the possibilities they were 14 for "abbcc" which are epislon, a, b, c, ab, abb, abbc, abbcc, bb, bbc, bbcc, bc, bcc, cc
â Beeee
Oct 30 '14 at 17:31
If you don't allow duplicates then my answer gives the maximum possible number of substrings and the minimum possible number is $n+1$, which occurs on the string consisting of one character repeating $n$ times.
â Solomonoff's Secret
Oct 30 '14 at 17:37
no I don't allow duplicates when I calculated it by writing down all the possibilities they were 14 for "abbcc" which are epislon, a, b, c, ab, abb, abbc, abbcc, bb, bbc, bbcc, bc, bcc, cc
â Beeee
Oct 30 '14 at 17:31
no I don't allow duplicates when I calculated it by writing down all the possibilities they were 14 for "abbcc" which are epislon, a, b, c, ab, abb, abbc, abbcc, bb, bbc, bbcc, bc, bcc, cc
â Beeee
Oct 30 '14 at 17:31
If you don't allow duplicates then my answer gives the maximum possible number of substrings and the minimum possible number is $n+1$, which occurs on the string consisting of one character repeating $n$ times.
â Solomonoff's Secret
Oct 30 '14 at 17:37
If you don't allow duplicates then my answer gives the maximum possible number of substrings and the minimum possible number is $n+1$, which occurs on the string consisting of one character repeating $n$ times.
â Solomonoff's Secret
Oct 30 '14 at 17:37
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f998559%2fis-there-a-mathematical-way-to-know-exactly-how-many-substrings-prefixes-suf%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password