Algorithm to find biggest three elements in array , iterate per 3 Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Computer Algorithm Running Time Calculation Complexity of sorting algorthmsWorst case complexity of the quicksort algorithmAlgorithm to find the second smallest elementAlgorithm to find stringMultiplying array elements$O(n)$ algorithm to determine a number that appears more than $n/2$ times in an array of size $n$(Interview Q, Algorithm) Elements in two unsorted array that sum to particular integerSimple sort worst case comparisonsHow do I find the estimated number of comparisons, using a sorting algorithm on a data set?

Weaponising the Grasp-at-a-Distance spell

Why is a lens darker than other ones when applying the same settings?

Relating to the President and obstruction, were Mueller's conclusions preordained?

Moving a wrapfig vertically to encroach partially on a subsection title

Rationale for describing kurtosis as "peakedness"?

Is openssl rand command cryptographically secure?

GDP with Intermediate Production

Did any compiler fully use 80-bit floating point?

Does the Mueller report show a conspiracy between Russia and the Trump Campaign?

Why is the change of basis formula counter-intuitive? [See details]

Special flights

Does the Black Tentacles spell do damage twice at the start of turn to an already restrained creature?

What does 丫 mean? 丫是什么意思?

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

Delete free apps from library

What order were files/directories output in dir?

Monty Hall Problem-Probability Paradox

How to change the tick of the color bar legend to black

How many time has Arya actually used Needle?

A proverb that is used to imply that you have unexpectedly faced a big problem

Simple Http Server

Should a wizard buy fine inks every time he want to copy spells into his spellbook?

What does it mean that physics no longer uses mechanical models to describe phenomena?

If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?



Algorithm to find biggest three elements in array , iterate per 3



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Computer Algorithm Running Time Calculation Complexity of sorting algorthmsWorst case complexity of the quicksort algorithmAlgorithm to find the second smallest elementAlgorithm to find stringMultiplying array elements$O(n)$ algorithm to determine a number that appears more than $n/2$ times in an array of size $n$(Interview Q, Algorithm) Elements in two unsorted array that sum to particular integerSimple sort worst case comparisonsHow do I find the estimated number of comparisons, using a sorting algorithm on a data set?










0












$begingroup$


So we have an array A with n different values.
n>0 and n is always divisible by 3. (Ex. n=3,n=6,n=9)
I have to find the biggest three elements in the array by iterating per group of 3 elements.



for(int i=0; i<n; i+=3)


The worst case is 2n-3 array comparisons.
So for n=3 , 3 array comparisons
n=6, 9 comparisons
n=9, 15 comparisons



I have to provide a pseudocode to give the Desired results.
I've tried many things but can't seem to find an algorithm that satisfies the worst case.
Desperate for hints or tips
Thanks in advance










share|cite|improve this question









$endgroup$
















    0












    $begingroup$


    So we have an array A with n different values.
    n>0 and n is always divisible by 3. (Ex. n=3,n=6,n=9)
    I have to find the biggest three elements in the array by iterating per group of 3 elements.



    for(int i=0; i<n; i+=3)


    The worst case is 2n-3 array comparisons.
    So for n=3 , 3 array comparisons
    n=6, 9 comparisons
    n=9, 15 comparisons



    I have to provide a pseudocode to give the Desired results.
    I've tried many things but can't seem to find an algorithm that satisfies the worst case.
    Desperate for hints or tips
    Thanks in advance










    share|cite|improve this question









    $endgroup$














      0












      0








      0





      $begingroup$


      So we have an array A with n different values.
      n>0 and n is always divisible by 3. (Ex. n=3,n=6,n=9)
      I have to find the biggest three elements in the array by iterating per group of 3 elements.



      for(int i=0; i<n; i+=3)


      The worst case is 2n-3 array comparisons.
      So for n=3 , 3 array comparisons
      n=6, 9 comparisons
      n=9, 15 comparisons



      I have to provide a pseudocode to give the Desired results.
      I've tried many things but can't seem to find an algorithm that satisfies the worst case.
      Desperate for hints or tips
      Thanks in advance










      share|cite|improve this question









      $endgroup$




      So we have an array A with n different values.
      n>0 and n is always divisible by 3. (Ex. n=3,n=6,n=9)
      I have to find the biggest three elements in the array by iterating per group of 3 elements.



      for(int i=0; i<n; i+=3)


      The worst case is 2n-3 array comparisons.
      So for n=3 , 3 array comparisons
      n=6, 9 comparisons
      n=9, 15 comparisons



      I have to provide a pseudocode to give the Desired results.
      I've tried many things but can't seem to find an algorithm that satisfies the worst case.
      Desperate for hints or tips
      Thanks in advance







      algorithms






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Apr 2 at 10:16









      AuruaAurua

      11




      11




















          0






          active

          oldest

          votes












          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%2f3171690%2falgorithm-to-find-biggest-three-elements-in-array-iterate-per-3%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          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%2f3171690%2falgorithm-to-find-biggest-three-elements-in-array-iterate-per-3%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

          Triangular numbers and gcdProving sum of a set is $0 pmod n$ if $n$ is odd, or $fracn2 pmod n$ if $n$ is even?Is greatest common divisor of two numbers really their smallest linear combination?GCD, LCM RelationshipProve a set of nonnegative integers with greatest common divisor 1 and closed under addition has all but finite many nonnegative integers.all pairs of a and b in an equation containing gcdTriangular Numbers Modulo $k$ - Hit All Values?Understanding the Existence and Uniqueness of the GCDGCD and LCM with logical symbolsThe greatest common divisor of two positive integers less than 100 is equal to 3. Their least common multiple is twelve times one of the integers.Suppose that for all integers $x$, $x|a$ and $x|b$ if and only if $x|c$. Then $c = gcd(a,b)$Which is the gcd of 2 numbers which are multiplied and the result is 600000?

          Ingelân Ynhâld Etymology | Geografy | Skiednis | Polityk en bestjoer | Ekonomy | Demografy | Kultuer | Klimaat | Sjoch ek | Keppelings om utens | Boarnen, noaten en referinsjes Navigaasjemenuwww.gov.ukOffisjele webside fan it regear fan it Feriene KeninkrykOffisjele webside fan it Britske FerkearsburoNederlânsktalige ynformaasje fan it Britske FerkearsburoOffisjele webside fan English Heritage, de organisaasje dy't him ynset foar it behâld fan it Ingelske kultuergoedYnwennertallen fan alle Britske stêden út 'e folkstelling fan 2011Notes en References, op dizze sideEngland

          Հադիս Բովանդակություն Անվանում և նշանակություն | Դասակարգում | Աղբյուրներ | Նավարկման ցանկ