Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project 1 Assignment SortingStudent Name:Class and Section:Total points are 2 5 ( each question is 5 points ) Question 1 . The bubble sort is

Project 1 Assignment SortingStudent Name:Class and Section:Total points are 25(each question is 5 points)Question 1.The bubble sort is O(n2). Like selection sort, bubble sort wont perform any swaps if the list isalready sorted. However, bubble sorts worst-case behavior for exchanges is greater than linear.The proof of this is left as an exercise for you. You can make a minor adjustment to the bubblesort to improve its best-case performance to linear. If no swaps occur during a pass through themain loop, then the list is sorted. This can happen on any pass, and in the best case will happenon the first pass. You can track the presence of swapping with a Boolean flag and return from thefunction when the inner loop does not set this flag. Write the modified bubble sort function.Create a list that contains 20 values from 1 to 20 in random order and test your modified bubblesort function.Question 2Explain the role that the number of data exchanges plays in the analysis of selection sort andbubble sort. What role, if any, does the size of the data objects play?Question 3.Explain why the modified bubble sort still exhibits O( n2) behavior on the average.Question 4Explain why insertion sort works well on partially sorted lists.Question 5Pythons list method sort includes the keyword argument reverse, whose default value is False.The programmer can override this value to sort a list in descending order. Modify theselectionSort function discussed in this lecture so that it allows the programmer to supply thisadditional argument to redirect the sort.

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 Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students also viewed these Databases questions

Question

Are limestones being formed today?

Answered: 1 week ago

Question

What is the use of bootstrap program?

Answered: 1 week ago

Question

What is a process and process table?

Answered: 1 week ago

Question

What is Industrial Economics and Theory of Firm?

Answered: 1 week ago