[Type C]Q12. Write a program to sort a dictionary’s values using Bubble sort and produce the sorted values as a list.


Program code:

Clear Doubts with Computer Tutor
In case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community: students.computertutor.in

Output:

[1, 4, 5, 8, 13, 22]

Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in the wrong order.

The first time we pass through the list the position n is guaranteed to be the largest element, the second time we pass through the position n-1 is guaranteed to be the second-largest element and so forth.

Basic python functionality is demonstrated in above program.

To view all the lessons in chapter 1: http://computertutor.in/class-12-computer-science/chapter-2/

To view entire class 12 computer science study material: http://computertutor.in/resources/

You cannot copy content of this page