Is there a mathematical way to know exactly how many substrings , prefixes , suffixes does a string have. for...
$begingroup$
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
$endgroup$
add a comment |
$begingroup$
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
$endgroup$
add a comment |
$begingroup$
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
$endgroup$
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
combinatorics discrete-mathematics
asked Oct 30 '14 at 17:14
BeeeeBeeee
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
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+1}n+2-s = (n+1)(n+2) - frac{(n+1)(n+2)}{2} = frac{(n+1)(n+2)}{2}.$$
$endgroup$
$begingroup$
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}
$endgroup$
– Beeee
Oct 30 '14 at 17:31
$begingroup$
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.
$endgroup$
– Solomonoff's Secret
Oct 30 '14 at 17:37
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
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
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
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+1}n+2-s = (n+1)(n+2) - frac{(n+1)(n+2)}{2} = frac{(n+1)(n+2)}{2}.$$
$endgroup$
$begingroup$
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}
$endgroup$
– Beeee
Oct 30 '14 at 17:31
$begingroup$
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.
$endgroup$
– Solomonoff's Secret
Oct 30 '14 at 17:37
add a comment |
$begingroup$
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+1}n+2-s = (n+1)(n+2) - frac{(n+1)(n+2)}{2} = frac{(n+1)(n+2)}{2}.$$
$endgroup$
$begingroup$
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}
$endgroup$
– Beeee
Oct 30 '14 at 17:31
$begingroup$
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.
$endgroup$
– Solomonoff's Secret
Oct 30 '14 at 17:37
add a comment |
$begingroup$
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+1}n+2-s = (n+1)(n+2) - frac{(n+1)(n+2)}{2} = frac{(n+1)(n+2)}{2}.$$
$endgroup$
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+1}n+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 SecretSolomonoff's Secret
3,65211233
3,65211233
$begingroup$
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}
$endgroup$
– Beeee
Oct 30 '14 at 17:31
$begingroup$
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.
$endgroup$
– Solomonoff's Secret
Oct 30 '14 at 17:37
add a comment |
$begingroup$
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}
$endgroup$
– Beeee
Oct 30 '14 at 17:31
$begingroup$
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.
$endgroup$
– Solomonoff's Secret
Oct 30 '14 at 17:37
$begingroup$
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}
$endgroup$
– Beeee
Oct 30 '14 at 17:31
$begingroup$
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}
$endgroup$
– Beeee
Oct 30 '14 at 17:31
$begingroup$
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.
$endgroup$
– Solomonoff's Secret
Oct 30 '14 at 17:37
$begingroup$
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.
$endgroup$
– Solomonoff's Secret
Oct 30 '14 at 17:37
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
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
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown