Hi! I am doing this function but it isn't working. how can I fix it
def bubble_down(values: list, left: int, right: int) -> None:
"""Bubble down through values[left: right+1], swapping items that are out
of order. Note that use of this slicing notation means that items
values[left], values[left + 1], values[left + 2], ..., values[right] could
be modified.
Precondition: left and right are valid indexes in values.
>>> list_example_1 = [4, 3, 2, 1, 0]
>>> bubble_down(list_example_1, 1, 3)
>>> list_example_1
[4, 1, 3, 2, 0]
>>> list_example_2 = [4, 3, 2, 1, 0]
>>> bubble_down(list_example_2, 0, 4)
>>> list_example_2
[0, 4, 3, 2, 1]
"""
for i in range(left, right):
if values[i] > values[i + 1]:
values[i], values[i + 1] = values[i + 1], values[i]
Step by stepSolved in 3 steps
- I am very confused on how to answer this and any thing will help. Create a function that accepts a single list. Inside the function, have nested for loops (a for loop inside a for loop). The outer for loop iterates through every item in the list. The inner loop iterates through every subitem in item, and prints it. Test the function by passing it the list [ [0, 1, 2], [3, 4, 5], [6, 7, 8] ].arrow_forward6. the grade is under 20 which is outlier, remove it from the array list. 7. Print array list using System.out.println() 8. Use indexOf to print index of 80. 9. Use get function. 10. What is the difference between get and index of? 11. Print the values of the array list using Iterator class. 12.. Delete all the values of the array list using clear function. 13. Print all the values of the array after you execute clear using System.out.println(). what is the result of using clear function? 14. What is the shortcoming of using array List?arrow_forwardThis is a pyhton , Coding the screenshot better explains. It talks about listarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education