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 )
Who is the author of the book titled ‘Fire on the Ganges’?
Who made history as the first Indian table tennis player to win a singles title in the WTT Contender tournament?
REC inks how many strategic MoUs in backdrop of Madhya Pradesh Global Investors Summit 2023?
What is the primary purpose of launching the integrated ERP solution and updated websites for Naval Schools, as mentioned in the event hosted on July 25...
A new variety of ______ naming PBW RS1 has been researched by Punjab Agricultural University (PAU).Â
According a report “Tech Start-ups: Quarterly Investment Factbook” recently, the total funding in the startup ecosystem dropped to what amou...
What is the main focus of the MoU approved between India's Ministry of Youth Affairs & Sports and Australia's Department of Health and Aged Care?
Stressed assets of commercial banks worth _____________ have been identified to be taken up in the first phase by the NARCL.
Which of the following best describes the impact of the Hangor-class submarines being built for Pakistan by China?
The Startup Mahakumbh event is significant for what reason?