Question
Which of the following is the last step for the
following input? Input: 310, 105, 45, 241, 417, 36, 281 Directions: A number arrange┬а machine, when given a particular input, rearranges it following a particular rule. The following is the illustration of the input and the steps of arrangement: Input: 207, 59, 324, 23, 135, 173, 312 Step I: 207, 59, 312, 23, 135, 173, 324 Step II: 23, 59, 312, 207, 135, 173, 324 Step III: 23, 59, 173, 207, 135, 312, 324 Step IV: 23, 59, 135, 207, 173, 312, 324 Step V: 23, 59, 135, 173, 207, 312, 324 This is the final arrangement and step V is the last step for this input.Solution
Here the rule followed is: Numbers are getting arranged in ascending order. The largest no. interchanges with the last-position no. Then the smallest no. interchanges with the first-position no. Next, the second largest no. interchanges with the second last position no. And so on.[Note: In step IV it is clear that when second smallest no.. is already set, the no. just larger to it interchanges with the next no.. From this it is clear that in odd step we should deal with larger no. and in even step we should deal with smaller no.] Last step can be found directly as the machine sets the given no. in ascending order.
рдирд┐рдореНрдирд▓рд┐рдЦрд┐рдд рдореЗрдВ рд╕реЗ рдХреМрди тАУ рд╕рд╛ рд╕реБрдореЗрд▓рд┐рдд рдпреБрдЧреНрдо рдирд╣реАрдВ┬а рд╣реИ ?┬а
рдЬрд┐рд╕ рдЫрдВрдж рдХреЗ рдкрд╣рд▓реЗ рддрдерд╛ рддреАрд╕рд░реЗ рдЪрд░рдгреЛрдВ рдореЗрдВ 13-13 рдФрд░ рджреВрд╕рд░реЗ рддрдерд╛ рдЪрд░рдгреЛрдВ рдоя┐╜...
рджрд┐рдП рдЧрдП рд╢рдмреНрдж рдХреЗ рдкрд░реНрдпрд╛рдп рдХреЗ рд▓рд┐рдП рдЪрд╛рд░ рдЪрд╛рд░ рд╡рд┐рдХрд▓реНрдк рджрд┐рдП рдЧрдП рд╣реИрдВред рдЙрдЪрд┐я┐╜...
рдиреАрдЪреЗ рджрд┐рдП рдЧрдП рдпреБрдЧ рдореЗрдВ рд╕рд╣реА рдпреБрдЧреНрдо рдХреЗ рд╡рд┐рдХрд▓реНрдк рдХреЛ рдЪрд┐рдиреНрд╣рд┐рдд рдХрд░реЗрдВ
тАШ рдЬрдм рд╡рд░реНрд╖рд╛ рд╣реЛрддреА рд╣реИ рддрдм рдирджреА рдореЗрдВ рдкрд╛рдиреА рднрд░ рдЬрд╛рддрд╛ рд╣реИредтАЩ рдпрд╣ рдХрд┐рд╕ рдкреНрд░рдХрд╛...
рдирд┐рдореНрдирд▓рд┐рдЦрд┐рдд рдЙрджреНрдзрд░рдг рдкрд░ рд╡рд┐рдЪрд╛рд░ рдХреАрдЬрд┐рдП:
тАЬ рднрд╛рд╖рд╛ рдХреА рд╕рд░рд▓рддрд╛ , рд╕рд╣рдЬрдд...
тАШ рдЬреЛтАШ рд╢рдмреНрдж рдХреМрди рд╕рд╛ рд╕рд░реНрд╡рдирд╛рдо рд╣реИ ?
рдирд┐рдореНрдирд▓рд┐рдЦрд┐рдд рдореЗрдВ рд╕реЗ рдПрдХ рд╡рд┐рд╢реЗрд╖рдг рд╢рдмреНрдж рдирд╣реАрдВ рд╣реИ:
'рдордХреНрдЦрд┐рдпрд╛рдБ рдорд╛рд░рдирд╛' рдореБрд╣рд╛рд╡рд░реЗ рдХрд╛ рд╕рд╣реА рдЕрд░реНрде рдХреНрдпрд╛ рд╣реИ?
.рдирд┐рдореНрдирд▓рд┐рдЦрд┐рдд рдореЗрдВ рд╕реЗ рдХреМрди рд╕рд╛ рд╕реБрдореЗрд▓рд┐рдд рдпреБрдЧреНрдо рдирд╣реАрдВ рд╣реИ┬а