ch-5 : Input-Output : Introduction & Formula


Ex. 1.  A number arrangement machine, when given an input of words, rearrange the numbers in a particular manner step by step as given below, till all the given words are arranged in a particular order.

INPUT   :  day step amiss up to block inside.

Step I     :  amiss day step upto block inside.

Step II    :  amiss block day step upto inside.

Step III   :  amiss block day inside step upto.

(and step III is the last step for this input of words)

Explanation

Method used to arrange the input in the above example appears to be simple if we observe each step of the arrangement minutely. Step III, which is the last step, shows that the given input has completely been arranged. In the last step, all words of the input have been arranged in alphabetical order. In other words, all words of input occupy the same order as they occupy in dictionary.

Methodology

Step I : In step I, select the word starting with a letter which appears in the dictionary first and place it in the beginning of the sentence (input) leaving other words unchanged. Hence, in step I the word ‘amiss’ has been placed in the first position.

        Step II : In step II, select the word starting with a letter which appears at second position in the dictionary and place the word at the second position of the sentence (input) leaving other words unchanged.

        Step III : Select the word starting with a letter which appears at the third position in dictionary and place the word at the third position of the sentence (input) leaving other words unchanged.

In the step III, we get all the words arranged in order of their positions in the dictionary, hence step III is our last step.

Ex. 2 :

Input    :  day step amiss upto block inside.

Step I    :  amiss day step upto block inside.

Step II   :  amiss inside day step up to block.

Step III  :  amiss inside upto day step block.

Step IV  : amiss inside upto block day step.

(And step IV is the last step for this input of words.)

Explanation

Method of arrangements used for the input in various steps of this example is the same as used in the Example 1, but with slight modifications. On going through the last arrangement of words in step IV, it is observed that words in the last step have been first grouped into two parts. In the first part we see that the words with their first letter starting with a vowel and in second part words with their first letter staring wth a consonant have been placed in order of their positions in the dictionary.

Methodology

       Step I : In step I, the word with the first letter starting with first vowel has been selected and placed at the first position of the sentence.

      Step II : In step II, the word with the first letter starting with the next vowel has been selected and placed at the second position of the sequence.

      Step III : In step III, the word with first letter starting with next vowel in order has been placed at the third position.

      Step IV : Now, after having placed all the words with their first letter starting with vowels in order of their positions in dictionary, the word with first letter starting with consonant which appears first in dictionary has been placed at the fourth position.

After placing the fourth word, we get the rest of the words automatically arranged and, hence step IV is the last step of the arrangement.

Here, we have seen that final arrangement of words comprises two parts. One starting with the word ‘amiss’, being the word starting with first letter with a vowel and second part starting with the word ‘block,’ being the word starting with a consonant that appears first in the dictionary and each part has then, been arranged separately by way of placing each word in order of their positions in dictionary.

Ex. 3 :

Input    :   85  16  36  04  19  97  63  09

Step I   :    97  85  16  36  04  19  63  09

Step II  :   97  85  63  16  36  04  19  09

Step III :  97  85  63  36  16  04  19  09

Step IV  :  97  85  63  36  19  16  04  09

Step V   :  97  85  63  36  19  16  09  04

(For the given input step V is the last step)

Explanation

On going through the steps, it becomes very clear that numbers are arranged in descending order.

Methodology

in each step, largest number in descending order has been selected and placed at first, second, third,…… positions. Hence, we get step V as the last step with all numbers arranged in descending order.