Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in python Implement these additional sorting algorithms: Quick, Modified Quick, Merge, and Counting. Test your sorting algorithms as you did in the previous assignment. import
in python
Implement these additional sorting algorithms: Quick, Modified Quick, Merge, and Counting. Test your sorting algorithms as you did in the previous assignment. import random def get_random_numbers(): randomlist = [] for i in range(0, random.randint(5,10)): n = random.randint(1,30) randomlist.append(n) return randomlist def bubble_sort(randomlist): for i in range(0, len(randomlist)-1): for j in range(0, len(randomlist)-i-1): if randomlist[j+1] randomlist[i+1]): randomlist[i], randomlist[i+1] = randomlist[i+1], randomlist[i] swapped = True if (swapped False): break swapped = False end = end-1 for i in range(end-1, start-1, -1): if (randomlist[i] > randomlist[i +1]): randomlist[i], ai + 1] = randomlist[i + 1], randomlist[i] swapped True start start + 1 return randomlist I def main(): print("How many times would you like to test?") number = int(input() for i in range(0, number): randomlist = get_random_numbers() bubble_sort_list = bubble_sort(randomlist) selection_sort_list = selection_sort(randomlist) shaker_sort_list = shaker_sort(randomlist) print("Random Numbers List:" , randomlist) print("Bubble Sort Result:", randomlist) print("selection Sort Result:", randomlist) print("Shaker Sort Result:", randomlist) randomlist.sort() print("Random List vs Bubble Sort Result:", randomlist == bubble_sort_list) print("Random List Vs Selection Sort Result:", randomlist == selection_sort_list) print("Random List Vs Shaker Sort Result:", randomlist == shaker_sort_list) main()Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started