Medians which lie in sequence of even length.











up vote
0
down vote

favorite












Given a sequence of numbers say [1,2,2,2,4,3,3] from this sequence how many sub-sequences in order can be formed in which the median will lie in the sub-sequences itself. I have found that for all sequences of odd length it will hold true. Therefore total number of sequences with odd length are nC1+nC3+nC5+...+nCn for current array n=7. Now I have also figured out that all the sequences of length 2 which can be formed are 3C2 + 2C2 i.e C(3,2) + C(2,2) That is it will be only possible if we have both the same in above example it will be [2,2] [2,2] [2,2] [3,3] the elements will be treated different if they are at different indices in sequence. How I will find number of other sequences of length 4,6... and other even length sequences.










share|cite|improve this question






















  • Can you clarify? When you say "in order", do you mean that the subsequences must be non-decreasing? Or just that the indices of the elements must be increasing?
    – Joey Kilpatrick
    Nov 5 at 20:45






  • 2




    I mean to say that the in the sub-sequence the order in which number are present should be followed that is for a sub-sequence Ai,Aj,Ak,Al...., 1<=i<j<k<l<.. and so on where i,j,k,l are positions of numbers in original sequence.
    – Mikhail Kosten
    Nov 5 at 20:52








  • 1




    This problem was taken from a contest that closed 12 November 2018.
    – quid
    Nov 13 at 8:23















up vote
0
down vote

favorite












Given a sequence of numbers say [1,2,2,2,4,3,3] from this sequence how many sub-sequences in order can be formed in which the median will lie in the sub-sequences itself. I have found that for all sequences of odd length it will hold true. Therefore total number of sequences with odd length are nC1+nC3+nC5+...+nCn for current array n=7. Now I have also figured out that all the sequences of length 2 which can be formed are 3C2 + 2C2 i.e C(3,2) + C(2,2) That is it will be only possible if we have both the same in above example it will be [2,2] [2,2] [2,2] [3,3] the elements will be treated different if they are at different indices in sequence. How I will find number of other sequences of length 4,6... and other even length sequences.










share|cite|improve this question






















  • Can you clarify? When you say "in order", do you mean that the subsequences must be non-decreasing? Or just that the indices of the elements must be increasing?
    – Joey Kilpatrick
    Nov 5 at 20:45






  • 2




    I mean to say that the in the sub-sequence the order in which number are present should be followed that is for a sub-sequence Ai,Aj,Ak,Al...., 1<=i<j<k<l<.. and so on where i,j,k,l are positions of numbers in original sequence.
    – Mikhail Kosten
    Nov 5 at 20:52








  • 1




    This problem was taken from a contest that closed 12 November 2018.
    – quid
    Nov 13 at 8:23













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Given a sequence of numbers say [1,2,2,2,4,3,3] from this sequence how many sub-sequences in order can be formed in which the median will lie in the sub-sequences itself. I have found that for all sequences of odd length it will hold true. Therefore total number of sequences with odd length are nC1+nC3+nC5+...+nCn for current array n=7. Now I have also figured out that all the sequences of length 2 which can be formed are 3C2 + 2C2 i.e C(3,2) + C(2,2) That is it will be only possible if we have both the same in above example it will be [2,2] [2,2] [2,2] [3,3] the elements will be treated different if they are at different indices in sequence. How I will find number of other sequences of length 4,6... and other even length sequences.










share|cite|improve this question













Given a sequence of numbers say [1,2,2,2,4,3,3] from this sequence how many sub-sequences in order can be formed in which the median will lie in the sub-sequences itself. I have found that for all sequences of odd length it will hold true. Therefore total number of sequences with odd length are nC1+nC3+nC5+...+nCn for current array n=7. Now I have also figured out that all the sequences of length 2 which can be formed are 3C2 + 2C2 i.e C(3,2) + C(2,2) That is it will be only possible if we have both the same in above example it will be [2,2] [2,2] [2,2] [3,3] the elements will be treated different if they are at different indices in sequence. How I will find number of other sequences of length 4,6... and other even length sequences.







sequences-and-series combinatorics permutations median






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Nov 5 at 18:12









Mikhail Kosten

71




71












  • Can you clarify? When you say "in order", do you mean that the subsequences must be non-decreasing? Or just that the indices of the elements must be increasing?
    – Joey Kilpatrick
    Nov 5 at 20:45






  • 2




    I mean to say that the in the sub-sequence the order in which number are present should be followed that is for a sub-sequence Ai,Aj,Ak,Al...., 1<=i<j<k<l<.. and so on where i,j,k,l are positions of numbers in original sequence.
    – Mikhail Kosten
    Nov 5 at 20:52








  • 1




    This problem was taken from a contest that closed 12 November 2018.
    – quid
    Nov 13 at 8:23


















  • Can you clarify? When you say "in order", do you mean that the subsequences must be non-decreasing? Or just that the indices of the elements must be increasing?
    – Joey Kilpatrick
    Nov 5 at 20:45






  • 2




    I mean to say that the in the sub-sequence the order in which number are present should be followed that is for a sub-sequence Ai,Aj,Ak,Al...., 1<=i<j<k<l<.. and so on where i,j,k,l are positions of numbers in original sequence.
    – Mikhail Kosten
    Nov 5 at 20:52








  • 1




    This problem was taken from a contest that closed 12 November 2018.
    – quid
    Nov 13 at 8:23
















Can you clarify? When you say "in order", do you mean that the subsequences must be non-decreasing? Or just that the indices of the elements must be increasing?
– Joey Kilpatrick
Nov 5 at 20:45




Can you clarify? When you say "in order", do you mean that the subsequences must be non-decreasing? Or just that the indices of the elements must be increasing?
– Joey Kilpatrick
Nov 5 at 20:45




2




2




I mean to say that the in the sub-sequence the order in which number are present should be followed that is for a sub-sequence Ai,Aj,Ak,Al...., 1<=i<j<k<l<.. and so on where i,j,k,l are positions of numbers in original sequence.
– Mikhail Kosten
Nov 5 at 20:52






I mean to say that the in the sub-sequence the order in which number are present should be followed that is for a sub-sequence Ai,Aj,Ak,Al...., 1<=i<j<k<l<.. and so on where i,j,k,l are positions of numbers in original sequence.
– Mikhail Kosten
Nov 5 at 20:52






1




1




This problem was taken from a contest that closed 12 November 2018.
– quid
Nov 13 at 8:23




This problem was taken from a contest that closed 12 November 2018.
– quid
Nov 13 at 8:23










1 Answer
1






active

oldest

votes

















up vote
1
down vote













Reposing the answer now that the contest has ended





First note that the problem does not change if we first sort the sequence. So the number of subsequences that contain its own median in the sequence $[1,2,2,2,4,3,3]$ is the same as that of $[1,2,2,2,3,3,4]$.



Suppose that we had a (sorted) even length subsequence $a_1,...,a_{2n}$ that contained its own median. Then the elements $a_{n}$ and $a_{n+1}$ must be equal. As in your post, you identified that the possibilities in your example for the elements $a_{n}$ and $a_{n+1}$ were $[2,2]$ (with multiplicity $3$) and $[3,3]$. The only possibilities for the median are those elements that appear multiple times in the array.



For an even length subsequence $a_n$, let the possible medians be the set $text{med}(a_n)$. For any element $a$ in the sequence, let $l(a)$ be the number of elements in the sequence less than $a$ and let $g(a)$ be the number of elements in the sequence greater than $a$. To construct a subsequence from a given $min text{med}(a_n)$, then for some $kle g(m), l(m)$, select $k$ elements that are less than $m$ and $k$ elements that are greater than $m$, and add them to the subsequence. The number of ways to do this is
$$
sum_{min text{med}(a_n)}left(
sum^{min{g(m),l(m)}}_{i=0}binom{g(m)}{i}binom{l(m)}{i}
right)
$$

However, this solution has a major issue. It assumes that there are always exactly $2$ elements in the subsequence equal to the median $m$. There must be at least $2$, but there could be more. Consider the subsequence $[1,2,2,2]$ from the example sequence. To fix this issue, let $n(m)$ be the multiplicity of $min text{med}(a_n)$,
$$
sum_{min text{med}(a_n)}left(
sum^{(n(m)-2)}_{x=0}
sum^{(n(m)-2-x)}_{y=0}
left(
sum^{min{g(m)+x,l(m)+y}}_{i=0}binom{g(m)+x}{i}binom{l(m)+y}{i}
right)
right)
$$

Using Vandermonde's identity, we can simplify the innermost sum,
$$
sum_{min text{med}(a_n)}left(
sum^{(n(m)-2)}_{x=0}
sum^{(n(m)-2-x)}_{y=0}
binom{(g(m)+x)+(l(m)+y)}{(g(m)+x)}
right)
$$

This equals the number of even length subsequences that contain their own median.






share|cite|improve this answer





















    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    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',
    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%2f2986089%2fmedians-which-lie-in-sequence-of-even-length%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








    up vote
    1
    down vote













    Reposing the answer now that the contest has ended





    First note that the problem does not change if we first sort the sequence. So the number of subsequences that contain its own median in the sequence $[1,2,2,2,4,3,3]$ is the same as that of $[1,2,2,2,3,3,4]$.



    Suppose that we had a (sorted) even length subsequence $a_1,...,a_{2n}$ that contained its own median. Then the elements $a_{n}$ and $a_{n+1}$ must be equal. As in your post, you identified that the possibilities in your example for the elements $a_{n}$ and $a_{n+1}$ were $[2,2]$ (with multiplicity $3$) and $[3,3]$. The only possibilities for the median are those elements that appear multiple times in the array.



    For an even length subsequence $a_n$, let the possible medians be the set $text{med}(a_n)$. For any element $a$ in the sequence, let $l(a)$ be the number of elements in the sequence less than $a$ and let $g(a)$ be the number of elements in the sequence greater than $a$. To construct a subsequence from a given $min text{med}(a_n)$, then for some $kle g(m), l(m)$, select $k$ elements that are less than $m$ and $k$ elements that are greater than $m$, and add them to the subsequence. The number of ways to do this is
    $$
    sum_{min text{med}(a_n)}left(
    sum^{min{g(m),l(m)}}_{i=0}binom{g(m)}{i}binom{l(m)}{i}
    right)
    $$

    However, this solution has a major issue. It assumes that there are always exactly $2$ elements in the subsequence equal to the median $m$. There must be at least $2$, but there could be more. Consider the subsequence $[1,2,2,2]$ from the example sequence. To fix this issue, let $n(m)$ be the multiplicity of $min text{med}(a_n)$,
    $$
    sum_{min text{med}(a_n)}left(
    sum^{(n(m)-2)}_{x=0}
    sum^{(n(m)-2-x)}_{y=0}
    left(
    sum^{min{g(m)+x,l(m)+y}}_{i=0}binom{g(m)+x}{i}binom{l(m)+y}{i}
    right)
    right)
    $$

    Using Vandermonde's identity, we can simplify the innermost sum,
    $$
    sum_{min text{med}(a_n)}left(
    sum^{(n(m)-2)}_{x=0}
    sum^{(n(m)-2-x)}_{y=0}
    binom{(g(m)+x)+(l(m)+y)}{(g(m)+x)}
    right)
    $$

    This equals the number of even length subsequences that contain their own median.






    share|cite|improve this answer

























      up vote
      1
      down vote













      Reposing the answer now that the contest has ended





      First note that the problem does not change if we first sort the sequence. So the number of subsequences that contain its own median in the sequence $[1,2,2,2,4,3,3]$ is the same as that of $[1,2,2,2,3,3,4]$.



      Suppose that we had a (sorted) even length subsequence $a_1,...,a_{2n}$ that contained its own median. Then the elements $a_{n}$ and $a_{n+1}$ must be equal. As in your post, you identified that the possibilities in your example for the elements $a_{n}$ and $a_{n+1}$ were $[2,2]$ (with multiplicity $3$) and $[3,3]$. The only possibilities for the median are those elements that appear multiple times in the array.



      For an even length subsequence $a_n$, let the possible medians be the set $text{med}(a_n)$. For any element $a$ in the sequence, let $l(a)$ be the number of elements in the sequence less than $a$ and let $g(a)$ be the number of elements in the sequence greater than $a$. To construct a subsequence from a given $min text{med}(a_n)$, then for some $kle g(m), l(m)$, select $k$ elements that are less than $m$ and $k$ elements that are greater than $m$, and add them to the subsequence. The number of ways to do this is
      $$
      sum_{min text{med}(a_n)}left(
      sum^{min{g(m),l(m)}}_{i=0}binom{g(m)}{i}binom{l(m)}{i}
      right)
      $$

      However, this solution has a major issue. It assumes that there are always exactly $2$ elements in the subsequence equal to the median $m$. There must be at least $2$, but there could be more. Consider the subsequence $[1,2,2,2]$ from the example sequence. To fix this issue, let $n(m)$ be the multiplicity of $min text{med}(a_n)$,
      $$
      sum_{min text{med}(a_n)}left(
      sum^{(n(m)-2)}_{x=0}
      sum^{(n(m)-2-x)}_{y=0}
      left(
      sum^{min{g(m)+x,l(m)+y}}_{i=0}binom{g(m)+x}{i}binom{l(m)+y}{i}
      right)
      right)
      $$

      Using Vandermonde's identity, we can simplify the innermost sum,
      $$
      sum_{min text{med}(a_n)}left(
      sum^{(n(m)-2)}_{x=0}
      sum^{(n(m)-2-x)}_{y=0}
      binom{(g(m)+x)+(l(m)+y)}{(g(m)+x)}
      right)
      $$

      This equals the number of even length subsequences that contain their own median.






      share|cite|improve this answer























        up vote
        1
        down vote










        up vote
        1
        down vote









        Reposing the answer now that the contest has ended





        First note that the problem does not change if we first sort the sequence. So the number of subsequences that contain its own median in the sequence $[1,2,2,2,4,3,3]$ is the same as that of $[1,2,2,2,3,3,4]$.



        Suppose that we had a (sorted) even length subsequence $a_1,...,a_{2n}$ that contained its own median. Then the elements $a_{n}$ and $a_{n+1}$ must be equal. As in your post, you identified that the possibilities in your example for the elements $a_{n}$ and $a_{n+1}$ were $[2,2]$ (with multiplicity $3$) and $[3,3]$. The only possibilities for the median are those elements that appear multiple times in the array.



        For an even length subsequence $a_n$, let the possible medians be the set $text{med}(a_n)$. For any element $a$ in the sequence, let $l(a)$ be the number of elements in the sequence less than $a$ and let $g(a)$ be the number of elements in the sequence greater than $a$. To construct a subsequence from a given $min text{med}(a_n)$, then for some $kle g(m), l(m)$, select $k$ elements that are less than $m$ and $k$ elements that are greater than $m$, and add them to the subsequence. The number of ways to do this is
        $$
        sum_{min text{med}(a_n)}left(
        sum^{min{g(m),l(m)}}_{i=0}binom{g(m)}{i}binom{l(m)}{i}
        right)
        $$

        However, this solution has a major issue. It assumes that there are always exactly $2$ elements in the subsequence equal to the median $m$. There must be at least $2$, but there could be more. Consider the subsequence $[1,2,2,2]$ from the example sequence. To fix this issue, let $n(m)$ be the multiplicity of $min text{med}(a_n)$,
        $$
        sum_{min text{med}(a_n)}left(
        sum^{(n(m)-2)}_{x=0}
        sum^{(n(m)-2-x)}_{y=0}
        left(
        sum^{min{g(m)+x,l(m)+y}}_{i=0}binom{g(m)+x}{i}binom{l(m)+y}{i}
        right)
        right)
        $$

        Using Vandermonde's identity, we can simplify the innermost sum,
        $$
        sum_{min text{med}(a_n)}left(
        sum^{(n(m)-2)}_{x=0}
        sum^{(n(m)-2-x)}_{y=0}
        binom{(g(m)+x)+(l(m)+y)}{(g(m)+x)}
        right)
        $$

        This equals the number of even length subsequences that contain their own median.






        share|cite|improve this answer












        Reposing the answer now that the contest has ended





        First note that the problem does not change if we first sort the sequence. So the number of subsequences that contain its own median in the sequence $[1,2,2,2,4,3,3]$ is the same as that of $[1,2,2,2,3,3,4]$.



        Suppose that we had a (sorted) even length subsequence $a_1,...,a_{2n}$ that contained its own median. Then the elements $a_{n}$ and $a_{n+1}$ must be equal. As in your post, you identified that the possibilities in your example for the elements $a_{n}$ and $a_{n+1}$ were $[2,2]$ (with multiplicity $3$) and $[3,3]$. The only possibilities for the median are those elements that appear multiple times in the array.



        For an even length subsequence $a_n$, let the possible medians be the set $text{med}(a_n)$. For any element $a$ in the sequence, let $l(a)$ be the number of elements in the sequence less than $a$ and let $g(a)$ be the number of elements in the sequence greater than $a$. To construct a subsequence from a given $min text{med}(a_n)$, then for some $kle g(m), l(m)$, select $k$ elements that are less than $m$ and $k$ elements that are greater than $m$, and add them to the subsequence. The number of ways to do this is
        $$
        sum_{min text{med}(a_n)}left(
        sum^{min{g(m),l(m)}}_{i=0}binom{g(m)}{i}binom{l(m)}{i}
        right)
        $$

        However, this solution has a major issue. It assumes that there are always exactly $2$ elements in the subsequence equal to the median $m$. There must be at least $2$, but there could be more. Consider the subsequence $[1,2,2,2]$ from the example sequence. To fix this issue, let $n(m)$ be the multiplicity of $min text{med}(a_n)$,
        $$
        sum_{min text{med}(a_n)}left(
        sum^{(n(m)-2)}_{x=0}
        sum^{(n(m)-2-x)}_{y=0}
        left(
        sum^{min{g(m)+x,l(m)+y}}_{i=0}binom{g(m)+x}{i}binom{l(m)+y}{i}
        right)
        right)
        $$

        Using Vandermonde's identity, we can simplify the innermost sum,
        $$
        sum_{min text{med}(a_n)}left(
        sum^{(n(m)-2)}_{x=0}
        sum^{(n(m)-2-x)}_{y=0}
        binom{(g(m)+x)+(l(m)+y)}{(g(m)+x)}
        right)
        $$

        This equals the number of even length subsequences that contain their own median.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Nov 13 at 22:50









        Joey Kilpatrick

        1,093121




        1,093121






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2986089%2fmedians-which-lie-in-sequence-of-even-length%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

            How to send String Array data to Server using php in android

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

            Is anime1.com a legal site for watching anime?