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 struggling with the deadlines of my assignments and increasingly felt at a loss with my undergrads law program at the Victoria Law College. 24 hours in a day were not enough to do the research and structure the assignment essay. At TheReliableTutor the tutors understand my deadlines and I have never had them delay.
The online finance thesis and dissertation writing helpers at TheReliableTutor guided me throughout the process of constructing my finance thesis essay. He helped me with the research and showed me how to structure the research and citations.
I was completely lost with my Thermodynamics assignment. I approached the HwA team for help and they connected me with the best chem engineering tutor ever. He not only cleared my concepts but also helped me in solving my assignments. Kudos team!
Initially I hesitated but after talking to one of the nursing assignment experts I was overwhelmed by the fact that she is from my university only and knew all our curriculums. I was so relaxed after that as HwA helped me out with all my assignments and helped me learn new things in nursing.
My professor gave an assignment where I had to make a marketing plan for a daily use product in the markets of Hastings, New Zealand. I was unsure whether anyone in the internet will be able to guide me with such accurate details. However, to my surprise I found out that HwA not only have separate Kiwi assignment helpers but there are marketing assignment experts also. I definitely got good grades and I am very happy with my results.
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.