Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make a program that: Asks a user to enter 20 grades. Each grade is put into a slot in an array. Print out the original

image text in transcribed

Make a program that: Asks a user to enter 20 grades. Each grade is put into a slot in an array. Print out the original values. Sort the grades, using a bubble sort, from highest grade to lowest grade. Then print out the sorted grades. Then, make another function with an improved bubble sort - explanations on changes are here. Make sure to test this function before you submit it.: Note: The traditional bubble sort is not efficient enough for large arrays. Make the following simple modifications to improve its performance. 1. After the first pass, the largest number is guaranteed to be in the highest- are "in place," and so on. Instead of making nine comparisons on every pass, modify the bubble sort to make eight comparisons on the second pass, seven on the third pass and so on. (This will match the Wikipedia version) 2. The data in the array may already be in the proper or near-proper order, so why make nine passes if fewer will suffice? Modify the sort to check at the end of each pass whether any swaps have been made. If none has been made, then the data must already be in the proper order, so the program should terminate. If swaps have been made, then at least one more pass is needed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 9th International Conference Dasfaa 2004 Jeju Island Korea March 2004 Proceedings Lncs 2973

Authors: YoonJoon Lee ,Jianzhong Li ,Kyu-Young Whang

2004th Edition

3540210474, 978-3540210474

More Books

Students also viewed these Databases questions

Question

Discuss the role of costs in setting final prices.

Answered: 1 week ago

Question

Explain the chemical properties of acids with examples.

Answered: 1 week ago

Question

Write the properties of Group theory.

Answered: 1 week ago