a) What are the contents of 'otherList after a single iteration of the outer loop of 'bubbleSort? b) How many iterations of the outer loop happen when sorting `otherList? * Then run both blocks of code (the def block and the test block) again. * Examine the output to answer the question about iterations. Create a new list below with * elements known as "yourList" - a list where you can get 'bubbleSort to stop early (do fewer iterations). How many times did the outer loop run for 'yourList?

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18PE
icon
Related questions
Question
Run the code below to call the function
# In[ ]:
otherList = [395,2,-4,20,47,200,-50,-12] #a list for testing
print ('Before sorting:', otherList)
bubbleSort (otherList)
print ('After sorting:', otherList)
a) What are the contents of otherList after a single iteration of the outer loop of 'bubbleSort?
b) How many iterations of the outer loop happen when sorting `otherList?
* Then run both blocks of code (the def block and the test block) again.
* Examine the output to answer the question about iterations.
Create a new list below with * elements known as "yourList" - a list where you can get 'bubbleSort` to stop
early (do fewer iterations). How many times did the outer loop run for 'yourList?
# In[ ]:
yourList = [] #fill in this list with 8 elements separated by commas
print ('Before sorting:', yourList)
bubbleSort (yourList)
print ('After sorting:', yourList)
Transcribed Image Text:Run the code below to call the function # In[ ]: otherList = [395,2,-4,20,47,200,-50,-12] #a list for testing print ('Before sorting:', otherList) bubbleSort (otherList) print ('After sorting:', otherList) a) What are the contents of otherList after a single iteration of the outer loop of 'bubbleSort? b) How many iterations of the outer loop happen when sorting `otherList? * Then run both blocks of code (the def block and the test block) again. * Examine the output to answer the question about iterations. Create a new list below with * elements known as "yourList" - a list where you can get 'bubbleSort` to stop early (do fewer iterations). How many times did the outer loop run for 'yourList? # In[ ]: yourList = [] #fill in this list with 8 elements separated by commas print ('Before sorting:', yourList) bubbleSort (yourList) print ('After sorting:', yourList)
Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Map
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning