Get in touch with us
Send us an e-mail
Question
A Bubble Sort algorithm as discussed in lectures is given below
index1 = 1;
repeat exchange = false;
{ for index2 ← length – 1 downto index1
{ if data[index2] < data[index2-1]
{ //exchange
exchange = true;
tmp = data[index2];
data[index2] = data[index2-1];
data[index2-1] = tmp;
}
}
index1 = index1 + 1;
} until (not exchange)
Apply this algorithm to the following data. Give the contents of the array after each pass (repeat loop) is completed. For each pass how many exchanges are made?
Note it may not be necessary to use all 7 passes.
Original Data 14 27 12 56 63 72 8 10
After Pass 1
Exchanges
After Pass 2
Exchanges
After Pass 3
Exchanges
After Pass 4
Exchanges
After Pass 5
Exchanges
After Pass 6
Exchanges
After Pass 7
Exchanges
How many comparisons will be made in total?
Download Full Solution
I was at a complete loss with the heavy course load and really desperately needed help with writing my Constitutional Law assignment essays. The constitutional law assignment experts at HwA are very professional and precise in their approach to dealing with the assignment topics. The research material and assignment content were 100% original and there was no hint of plagiarism.
While I took occasional help for my different assignments from TheReliableTutors, I kept on wondering whether they could actually help with my MBA dissertation paper. When I first approached them, they sounded confident and they already knew what is needed to be done. That was very relieving as even before my professor told me what to be done next, the dissertation expert knew what to do. I have got an “A†in my master’s dissertation report and now I have assigned them by PhD thesis paper also.
I was on the verge of failing my course when i found these guys. The tutors are excellent. They helped me improve my grade and pass the course with flying colors.
I used to always avoid metallurgy and concentrated in other sections of chemical engineering. However, a miracle happened 2 years ago. As I was stuck with my mechanical properties assignment, I came across HwA. Now, thanks to them, in my last semester I am thinking of doing my master degree in metallurgy. The material science experts of HwA did not only help me get good grades in the material science assignments but at the same time made me fall in love.
I wanted to do a dissertation on consumer behavior but was confused on how to identify a topic and write a report. The dissertation advisors here at TheReliableTutor had an online live session with me and after understanding my requirements they came up with three suggested Research Proposal Writing topics.
Comments
this is a very good website
I have 50 questions for the same test your page is showing only 28
hi can you please help or guide me to answer my assignments. thanks
hi can anyone help or guide me to my assignments. thanks
This solution is perfect ...thanks
Hello Allison,I love the 2nd image that you did! I also, had never heard of SumoPaint, is something that I will have to exolpre a bit! I understand completely the 52 (or so) youtube videos that you probably watched. Sometimes they have what you want, sometimes they don't! However, it is always satisfying when you are able to produce something that you have taught yourself. Great job!Debra 0 likes
Perfect bank of solution.
great !
thanks for the quick response. the solution looks good. :)
thnx for the answer. it was perfect. just the way i wanted it.
works fine.