Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

boolean is _ sorted ( lyst ) : This is a predicate function that returns True if lyst is sorted, False otherwise. In addition to

boolean is_sorted(lyst): This is a predicate function that returns True if lyst is sorted, False otherwise. In addition to verifying that lyst is a list, is_sorted() must also verify that every element in the list is an integer. If lyst is not a list, or a non-integer element is found in it, is_sorted should raise a TypeError exception. Note: We recommend implementing this function first, so that you can use it to do unit testing as you develop your sorting functions.
(list, int, int) quicksort(lyst): This function implements the quicksort algorithm to sort the items in lyst. the function returns a tuple containing the sorted list, followed by the number of comparisons, and finally the number of swaps performed while sorting. lyst must be a Python list containing comparable data (i.e. things that the >,<, etc. operators can be used on to determine an ordering between two items). If lyst is not a list, quicksort() must raise a TypeError Exception.
(list, int, int) mergesort(lyst): This function implements the mergesort algorithm to sort the items in lyst. the function returns a tuple containing the sorted list, followed by the number of comparisons, and finally the number of swaps performed while sorting. lyst must be a Python list containing comparable data (i.e. things that the >,<, etc. operators can be used on to determine an ordering between two items). If lyst is not a list, mergesort() must raise a TypeError Exception.
(list, int, int) selection_sort(lyst): This function implements the selection sort algorithm to sort the items in lyst. the function returns a tuple containing the sorted list, followed by the number of comparisons, and finally the number of swaps performed while sorting. lyst must be a Python list containing comparable data (i.e. things that the >,<, etc. operators can be used on to determine an ordering between two items). If lyst is not a list, selection_sort() must raise a TypeError Exception.
(list, int, int) insertion_sort(lyst): This function implements the insertion sort algorithm to sort the items in lyst. the function returns a tuple containing the sorted list, followed by the number of comparisons, and finally the number of swaps performed while sorting. lyst must be a Python list containing comparable data (i.e. things that the >,<, etc. operators can be used on to determine an ordering between two items). If lyst is not a list, insertion_sort() must raise a TypeError Exception.

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

More Books

Students also viewed these Databases questions