Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am so confused with this question: In python pls Write a function called compare_sorts_worst_case(steps) which takes a list of integers as a parameter and

I am so confused with this question:

image text in transcribedIn python pls

Write a function called compare_sorts_worst_case(steps) which takes a list of integers as a parameter and produces a summary of the number of comparisons and swaps that are required to sort a list of descending integers using Bubble Sort, Selection Sort and Insertion Sort (i.e. the worst case scenario). The table is formatted as follows: Each column has a width of 10 characters, and the content of the column is aligned to the right edge of that column The columns are separated with a "|"(i.e. ). The first column of the table shows the number of integers used in the sorting algorithm, and has a column header N. For example, if the value is 8, the numbers you should use for the list are: [8,7,6,5,4,3,2,1] The second and third columns of the table show the number of comparisons and swaps respectively in the bubble sort algorithm and has the column header BUB COMP and BUB SWAP respectively. The fourth and fifth columns of the table show the number of comparisons and swaps respectively in the selection sort algorithm and has the column header SEL COMP and SEL SWAP respectively. The sixth and seventh columns of the table show the number of comparisons and swaps respectively in the insertion sort algorithm and has the column header INS COMP and INS SWAP respectively. The second row of the table has a horizontal line of '-' characters. Note: you may not use Python's built in sort() or sorted functions. Copy the insertion_sort, bubble_sorto, selection_sort() function defined in the previous lab. For example: Test Result compare_sorts_worst_case([1,2,4,8]) N BUB COMP BUB SWAP SEL COMP SEL SWAP INS COMP INS SWAP 1 2 4 ol 11 61 28 1 61 28 1 61 28 0 11 31 71 0 1 6 28 0 1 6 28 Write a function called compare_sorts_worst_case(steps) which takes a list of integers as a parameter and produces a summary of the number of comparisons and swaps that are required to sort a list of descending integers using Bubble Sort, Selection Sort and Insertion Sort (i.e. the worst case scenario). The table is formatted as follows: Each column has a width of 10 characters, and the content of the column is aligned to the right edge of that column The columns are separated with a "|"(i.e. ). The first column of the table shows the number of integers used in the sorting algorithm, and has a column header N. For example, if the value is 8, the numbers you should use for the list are: [8,7,6,5,4,3,2,1] The second and third columns of the table show the number of comparisons and swaps respectively in the bubble sort algorithm and has the column header BUB COMP and BUB SWAP respectively. The fourth and fifth columns of the table show the number of comparisons and swaps respectively in the selection sort algorithm and has the column header SEL COMP and SEL SWAP respectively. The sixth and seventh columns of the table show the number of comparisons and swaps respectively in the insertion sort algorithm and has the column header INS COMP and INS SWAP respectively. The second row of the table has a horizontal line of '-' characters. Note: you may not use Python's built in sort() or sorted functions. Copy the insertion_sort, bubble_sorto, selection_sort() function defined in the previous lab. For example: Test Result compare_sorts_worst_case([1,2,4,8]) N BUB COMP BUB SWAP SEL COMP SEL SWAP INS COMP INS SWAP 1 2 4 ol 11 61 28 1 61 28 1 61 28 0 11 31 71 0 1 6 28 0 1 6 28

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 Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions