Given the array {9, 20, 14, 17, 85, 3, 21, 6, 4, 10}, determine the number of comparisons used by: - Bubble Sort - Insertion Sort - Selection Sort - Merge Sort - Quick Sort - Heap Sort
Added by Jeremy F.
Step 1
### Bubble Sort Show more…
Show all steps
Your feedback will help us improve your experience
Rosemary Charnley and 82 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Akash M.
Processing time of InsertionSort is c · n^2. To merge k pre-sorted subarrays that contain together n items, you have to compare the k top items in all the sub-arrays to choose the current maximum item and place it into the sorted array (assuming that all the items have to be sorted in ascending order). Therefore, the time for merging is proportional to (k - 1) · n. Let the processing time of the merge be c · (k - 1) · n where the scale factor has the same value as for InsertionSort. Analyze whether it is possible to accelerate sorting of n items in the following way: - Split the initial array of size n into k subarrays of size n/k. The last subarray may be longer to preserve the total number of items n, but do not go into such details in your analysis. - Sort each subarray separately by InsertionSort. - Merge the sorted subarrays into a final sorted array. If you have found that the acceleration is possible, then find the optimum value of k and compare the resulting time complexity of this sorting algorithm to that of InsertionSort and MergeSort.
Aarya B.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD