Question
1) A simple sorting algorithm is called a Bubble Sort because elements bubble around through the list. It is also called a Sinking Sort because
1) A simple sorting algorithm is called a "Bubble Sort" because elements bubble around through the list. It is also called a "Sinking Sort" because the larger values "sink" to the end (bottom) of the list. A bubble sort iterates through a list and swaps adjacent pairs if they are in the wrong order. The sort continues until all elements are correctly ordered.
Example: bubbleSort([0, 1, 8, 4, 3, 2, 9]) - as it begins to process will compare 0 and one and make no change, then 1 and 8 again no change, then 8 and 4 and swap them. This process would repeat until we get [0,1,2,3,4,8,9]
a) Using Python, write an implementation of a bubble sort
b) Create a test to validate your bubble sort. Provide at least three input lists and compare the output to the output you would expect. You can use the example above as one of your test sets
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