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 )
In the sentence, certain words are in bold and numbered from A to E, which are the possible pairs to be interchanged. Choose the pair(s) of words which...
In each of the following sentences, identify the part that contains an error. If there is no error, choose option (E).
When the regulatory auth...
The committee of experts, along with their assistants, were /reviewing the final report and will submit/ it to the board next week after they/ has finis...
Spot the grammatical errors in the given sentence. Mark the part with error as your answer. If there is no error, mark "No error" as the answer. (Ignor...
Read each sentence to find out whether there is any grammatical error in it. The error, if any, will be in one part of the sentence. Mark the part with...
The nonagenarian artist is quite satisfied through the work carried out by the foundation.
In the following question, a sentence is given, divided into five parts. Part in bold is grammatically correct. Out of the other four parts, one part c...
1) Parents must
2) council there
3) children against the
4) use of mobile phones.
5) No error
In the context of an increasingly competitive global market, the companyโs reliance on outdated technology not only hampers its productivity but also ...
- Read each sentence to find out whether there is any grammatical error in it. The error, if any, will be in one part of the sentence. Mark the part with the...