Is there a mathematical way to know exactly how many substrings , prefixes , suffixes does a string have. for...












0












$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 .










share|cite|improve this question









$endgroup$

















    0












    $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 .










    share|cite|improve this question









    $endgroup$















      0












      0








      0





      $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 .










      share|cite|improve this question









      $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






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Oct 30 '14 at 17:14









      BeeeeBeeee

      1




      1






















          1 Answer
          1






          active

          oldest

          votes


















          0












          $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}.$$






          share|cite|improve this answer









          $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












          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
          });


          }
          });














          draft saved

          draft discarded


















          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









          0












          $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}.$$






          share|cite|improve this answer









          $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
















          0












          $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}.$$






          share|cite|improve this answer









          $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














          0












          0








          0





          $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}.$$






          share|cite|improve this answer









          $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}.$$







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          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


















          • $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


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Human spaceflight

          Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

          張江高科駅