Question
5,1,4,2,8 how many more pass are needed to finish
sorting by bubble sorting technique?Solution
First Pass: ( 5 1 4 2 8 ) –> ( 1 5 4 2 8 ), Here, algorithm compares the first two elements, and swaps since 5 > 1. ( 1 5 4 2 8 ) –> ( 1 4 5 2 8 ), Swap since 5 > 4 ( 1 4 5 2 8 ) –> ( 1 4 2 5 8 ), Swap since 5 > 2 ( 1 4 2 5 8 ) –> ( 1 4 2 5 8 ), Now, since these elements are already in order (8 > 5), algorithm does not swap them. Second Pass: ( 1 4 2 5 8 ) –> ( 1 4 2 5 8 ) ( 1 4 2 5 8 ) –> ( 1 2 4 5 8 ), Swap since 4 > 2 ( 1 2 4 5 8 ) –> ( 1 2 4 5 8 ) ( 1 2 4 5 8 ) –> ( 1 2 4 5 8 ) Now, the array is already sorted, but our algorithm does not know if it is completed. The algorithm needs one whole pass without any swap to know it is sorted. Third Pass: ( 1 2 4 5 8 ) –> ( 1 2 4 5 8 ) ( 1 2 4 5 8 ) –> ( 1 2 4 5 8 ) ( 1 2 4 5 8 ) –> ( 1 2 4 5 8 ) ( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )
If a meaningful English word is formed by using the 2nd, 4th, 5th, and 8th letters (from the left end) of t...
Four words have been given, out of which three are alike in some manner and one is different. Select the word that is different.
A group of alphabets are given with each being assigned a number. These have to be unscrambled into a meaningful word and correct the order of letters m...
Two statements are given, followed by three conclusions numbered I, II and III. Assuming the statements to be true, even if they seem to be at variance...
3 : 12 :: 6 : ?
Which alphabet is 3rd from the left in the meaningful four-letter word formed from the first, fifth, seventh and eighth letter of the word ‘HABILITATI...
If it is possible to make a meaningful English word from 2nd, 3rd, 5th, and 9th letter of the word "PERMANENT" from the left end, then what will be the ...
In the question, assuming the given statements to be true, find which of the conclusion (s) among given two conclusions is /are definitely true and the...
- Given in the table are the number codes for the given letters. Select the combination of numbers so that the letters arranged accordingly will form a meani...
Select the combination of numbers so that the letters arranged accordingly will form a meaningful English word.