Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def bubbleSort(numList): ''' Takes a list and returns 2 values 1st returned value: a dictionary with the state of the list after each complete pass

image text in transcribed
def bubbleSort(numList):
'''
Takes a list and returns 2 values
1st returned value: a dictionary with the state of the list after each complete pass of bubble sort
2nd returned value: the sorted list
>>> bubbleSort([2,3,5,4,1])
({1: [2, 3, 4, 1, 5], 2: [2, 3, 1, 4, 5], 3: [2, 1, 3, 4, 5], 4: [1, 2, 3, 4, 5]}, [1, 2, 3, 4, 5])
'''
# Your code starts here
The nte name must De LABIZ.py (incorect name les will gta-1 pomt deluaion A doctest is provided as an example of code functionality. Getting the same result as the doctest does not guarantee full credit. You are responsible for testing your code with enough data as possible. Each function must return the output (Do not use print in your final submission otherwise, you will get a-1 pt deduction) Do not include test code outside any function in the upload. Remove all your testing code before uploading your file. Do not inchude the input0 function in your submission. - - Goal: [10 pts] As discussed in class, bubble sort is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. Write the function bubbleSort numListy that takes an unsorted list of numbers and uses the bubble sort algorithm to return the sorted list. The function should also returns a dictionary with the state of the list after each complete pass. - You are not allowed to use the sorted0 method or the sort operator. Your code will not get credit if you use them EXAMPLES: >>>bubbleSort ([2,3, 5,4,1]) 3, 4, 5]1, [1, 2, 3, 4, 51) Second returned value, the sorted list This is another valid output: >> bubblesort (12,3,5, 4,11) 2121.512: 12, 3. 1. . 1. 3 12. 1, 3, 4, s)1. 4: t1, 2. 3, 4, 51, 5: 11, 2, 3, 4, 511, 11, 2, 3, 4, 5) Second returned value, the sorted list Deliverables: Submit your code in a file name LAB12.py to the Lab12 CANVAS assignment before the due date . MacBook Air

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

You have to agree that 50,000,000 U.S. citizens cannot be wrong.

Answered: 1 week ago