Question: Write Code in Python def bubbleSort(numList): ''' Takes a list and returns 2 values 1st returned value: a dictionary with the state of the list

Write Code in Python

Write Code in Python def bubbleSort(numList): ''' Takes a list and returns

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

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(numList) 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 sorted() method or the sort operator. Your code will not get credit if you use thenm EXAMPLES >>> bubbleSort ([2,3,5,4,1]) 3, 4, 5]}, [1, 2, 3, 4, 5]) Second returned value, the sorted list This is another valid output >>> bubbleSort ([2, 3,5,4,1]) 3, 4, 5]}, 5: [1, 2, 3, 4, 5]}, [1, 2, 3, 4, 5]) Second returned value, the sorted list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!