A word arrangement machine, when given an input line of words, rearranges them step by step following a particular rule. An illustration of an input and its rearrangement is given below.
Input: pearl girl cloud ship frog bench
Step I: bench pearl girl cloud ship frog
Step II: bench cloud pearl girl ship frog
Step III: bench cloud frog pearl girl ship
Step IV: bench cloud frog girl pearl ship
Step IV is the last step of this input.
Input: violet ocean grape lemon cherry plum mint
Following the same rule, how many steps will be needed to complete the arrangement of this input?
Answer & explanation
Correct answer: option 4
The correct answer is Option (4) → Six
Compare each step of the illustration with the one before it. In each step, the word that comes first in dictionary order among the words not yet arranged moves to the next place from the left end, and all the other words keep their order.
Step I: ‘bench’ comes first in dictionary order, so it moves to the first place from the left
Step II: ‘cloud’ comes first in dictionary order, so it moves to the second place from the left
Step III: ‘frog’ comes first in dictionary order, so it moves to the third place from the left
Step IV: ‘girl’ comes first in dictionary order, so it moves to the fourth place from the left
After Step IV the words stand in dictionary order, so the arrangement is complete.
Apply the same rule to the input violet ocean grape lemon cherry plum mint.
Step I: ‘cherry’ comes first in dictionary order, so it moves to the first place from the left, giving cherry violet ocean grape lemon plum mint
Step II: ‘grape’ comes first in dictionary order, so it moves to the second place from the left, giving cherry grape violet ocean lemon plum mint
Step III: ‘lemon’ comes first in dictionary order, so it moves to the third place from the left, giving cherry grape lemon violet ocean plum mint
Step IV: ‘mint’ comes first in dictionary order, so it moves to the fourth place from the left, giving cherry grape lemon mint violet ocean plum
Step V: ‘ocean’ comes first in dictionary order, so it moves to the fifth place from the left, giving cherry grape lemon mint ocean violet plum
Step VI: ‘plum’ comes first in dictionary order, so it moves to the sixth place from the left, giving cherry grape lemon mint ocean plum violet
After Step VI all the words are in their final places, so Step VI is the last step: six steps are needed.