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 all the prime digits of the number 2786989346 are written first (in increasing order) followed by even digits(in increasing order) and then odd digit...
How many pairs of letters are there in the word COMPARISONâ which has as many letters between them (both forward and backward) in the word as in the E...
If in the word âFRAGRANCEâ, all vowels are replaced by its next letter and all consonant is replaced by its previous letter, then all letters are ar...
How many pairs of letters are there in the word 'FREEZING' which has as many letters between them in the word (both forward and backward) as in the Eng...
If third letter from the left end of each word from each group is to be considered, then which among the following group of words can make at least one ...
How many pairs of letters are there in the word "PROSPECTUS" which has as many letters between them (both in forward and backward direction) in the wor...
If all the letters in the word âSHARINGâ are arranged in alphabetical order from left to right such that the vowels are arranged first followed by t...
If we arrange all the letters of the word âHESITATION in alphabetical order from the left end, then, how many letters will remain at same position aft...
How many such pairs of letters are there in the word âSUMMERâ that maintain their positional sequence as in the English alphabetical series (both fo...
If it is possible to make to make only one meaningful word with the first, second, fifth and seventh letters of the word âSTRAWBERRYâ, which of the...