Question
Which of the following will be the last step for the
following input? Input: 35 50 80 95 75 45 65 85 25 60 Directions : Study the following information to answer the given questions: A number sorting machine, when given an input of numbers, rearranges the numbers in a particular manner step by step as indicated below till all the numbers are arranged in a particular order. Input: 17 56 32 70 81 25 77 92 52 23 60 97 Step I: 17 23 32 70 81 25 77 92 52 56 60 97 Step II: 17 23 32 70 81 25 77 60 52 56 92 97 Step III: 17 23 25 70 81 32 77 60 52 56 92 97 Step IV: 17 23 25 70 56 32 77 60 52 81 92 97 Step V: 17 23 25 32 56 70 77 60 52 81 92 97 Step VI: 17 23 25 32 56 70 52 60 77 81 92 97 Step VII: 17 23 25 32 52 70 56 60 77 81 92 97 Step VIII: 17 23 25 32 52 60 56 70 77 81 92 97 Step IX: 17 23 25 32 52 56 60 70 77 81 92 97 and step IX is the last step for the given input.Solution
Here the rule followed is: Step I: The smallest number interchanges its position with the first number. [In case the first number is smallest then the next number just larger than it interchanges its position with the second number.] Step II: The largest number interchanges its position with the last number. [In case the largest number is first from right end, the second largest number interchanges its position with the second number from right and so on.] These steps are repeated alternately till the numbers get arranged in ascending order and that will be the last step for the particular input. Because all the numbers in this step are arranged in ascending order.
рдирд┐рдореНрд▓рд┐рдЦрд┐рдд рдореЗрдВ рд╕реЗ рд╢реБрджреНрдз рд╢рдмреНрдж┬ардЫрд╛рдБрдЯрд┐рдП┬а
рдореБрдЭ рдкрд░(1)/ рдХрд░реЗрдВ (2)/ рджрдпрд╛(3)/ рд╣реЗ рджреЗрд╡ (4)
рд╡рд╛рдХреНрдп рд╕рдВрд░рдЪрдирд╛ рдХрд╛ рд╕рд╣я┐╜...
рдирд┐рдореНрди рдореЗрдВ рд╕реЗ рд╢реБрджреНрдз рд╢рдмреНрдж рдХрд╛ рдЪрдпрди рдХреАрдЬрд┐рдП -;
рдордзреБрдореЗрд╣, рдЙрдЪреНрдЪ рд░рдХреНрддрдЪрд╛рдк рдФрд░ рдЕрдиреНрдп рд╣реГрджрдп рд╕рдВрдмрдВрдзреА рдмреАрдорд╛рд░реАрдУрдВ рд╕реЗ _____________...
рдирд┐рдореНрдирд▓рд┐рдЦрд┐рдд рдкреНрд░рд╢реНрдиреЛрдВ рдореЗрдВ рджрд┐рдпреЗ рдЧрдпреЗ рдкрд╛рдВрдЪ рд╡рд┐рдХрд▓реНрдкреЛрдВ рдореЗрдВ рд╕реЗ рд╢реБя┐╜...
рдирд┐рдореНрдирд▓рд┐рдЦрд┐рдд рдкреНрд░рддреНрдпреЗрдХ рдкреНрд░рд╢реНрди рдореЗрдВ рджрд┐рдпреЗ рдЧрдпреЗ рдЪрд╛рд░ - рдЪрд╛рд░ рд╡рд┐рдХрд▓реНрдкреЛ...
рдиреАрдЪреЗ рджрд┐рдпрд╛ рдЧрдпрд╛ рдкреНрд░рддреНрдпреЗрдХ рд╡рд╛рдХреНрдп рдЪрд╛рд░ рднрд╛рдЧреЛрдВ рдореЗрдВ рдмрд╛рдВрдЯрд╛ рдЧрдпрд╛ рд╣реИ рдЬя┐╜...
рджрд┐рдП рдЧрдП рд╡рд╛рдХреНрдп рдореЗрдВ рдХрд╛рд▓реЗ рднрд╛рдЧ рдХреЗ рд▓рд┐рдП рдЙрдкрдпреБрдХреНрдд рдПрдХ рд╢рдмреНрдж рдЪреБрдирд┐рдПред
рдореБрдЭреЗ рдмрд╣реБрдд рд╣реА рдореАрдард╛ рдЦрд╛рдирд╛ рдкрд╕рдВрдж рдХрд░рддреА рд╣реВрдБред┬а┬а
рдирд┐рдореНрди рд▓рд┐рдЦрд┐рдд рдкреНрд░рддреНрдпреЗрдХ рдкреНрд░рд╢реНрди рдХреЛ рдЪрд╛рд░ рднрд╛рдЧреЛрдВ рдореЗрдВ рдмрд╛рдВрдЯрд╛ рдЧрдпя┐╜...