Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8. Consider the following list: 28, 18, 21, 10, 25, 30, 12, 71, 32, s8, 15 This list is to be sorted using the insertion

image text in transcribed
8. Consider the following list: 28, 18, 21, 10, 25, 30, 12, 71, 32, s8, 15 This list is to be sorted using the insertion sort algorithm. Show the resulting list after six passes of the sorting phase -that is, after six iterations of the for loop. 18, 8, 11, 9, 15, Perform the insertion sort algorithm using the following list of keys: 20, 32, 61, 22, 48, 75, 83, 35, 3 Show the list after each iteration. Exactly how many key comparisons are exec sort this list using insertion sort? 9. 10. a. The performance of bubble sort can be improved if we stop the sorting process as soon as we find that in an iteration, no swapping of elements takes place. Write a function that implements bubble sort algorithm using this fact. b. Using the algorithm that you designed in part (a), find the number of iterations that are needed to sort the list: 65, 14, 52, 43, 75, 25, 80, 90, 95. 11. Suppose that L is a sorted list of 4096 elements. What is the maximum number of comparisons made by binary search to determine whether an item is in L? 12. Suppose that the elements of a list are in descending order, and they need to be put in ascending order. Write a C++ function that takes as input an array of items in descending order and the number of elements in the array. The function must not incorporate any sorting algorithms, that is, no item (key) comparisons should take place

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_2

Step: 3

blur-text-image_3

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

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

More Books

Students also viewed these Databases questions

Question

Demonstrate the difference between ability and personality tests.

Answered: 1 week ago

Question

Question May a taxpayer roll over money from an IRA to an HSA?

Answered: 1 week ago

Question

Question What is the doughnut hole in HSA coverage?

Answered: 1 week ago