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 )
How is F related to C?
Answer the questions based on the information given below.
Nine persons F, G, H, I, J, K, L, M, and N belong to a family of two generations. No...
If Aman is the brother of Babita; Babita is the sister of Chetan and Chetan is the father of Deep, how Deep is related to Aman?
How is E related to H?
If father of V is brother of mother of W’s wife’s brother. How is sister of husband of mother of V related to W’s son’s mother’s brother’s ...
How is M related to O?
How is O related to mother of L?
Which among the following is/are the husband-wife pair?
...How many male members are there in the family?
- Ankita is sister of the son of Gautam. Deepak’s wife is mother of Suravi. Lata is grandmother of Suravi. There are two married couple in the family. How ...