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 )
Which, among the following option(s) , is/are definitely true?
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 T’s father related to W, if W is a female?
- A + B means ‘A is the mother of B’; A – B means ‘A is the husband of B’; A × B means ‘A is the son of B’; A ÷ B means ‘A is the daughter ...
How is W related to S?
If ‘P × Q’ mean ‘Q is the sister of P’, ‘P + Q’ means ‘Q is the daughter of P’ , ‘P ÷ Q’ means ‘P is the wife of Q’, and ‘P-...
If E does not have any Granddaughter, then how many female members are there in the family?
Who among the following person is the son of G?
How is U related to W?
Pointing to a boy in the picture, Manisha said, “His fathers’s sister is the only daughter of my father’s father.” How is the boy’s father re...