Email iconarrow-down-circleGroup 8Path 3arrow-rightGroup 4Combined Shapearrow-rightGroup 4Combined ShapeUntitled 2Untitled 2Path 3ozFill 166crosscupcake-icondribbble iconGroupPage 1GitHamburgerPage 1Page 1LinkedInOval 1Page 1Email iconphone iconPodcast ctaPodcast ctaPodcastpushpinblog icon copy 2 + Bitmap Copy 2Fill 1medal copy 3Group 7twitter icontwitter iconPage 1

Bubble sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps 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 a program that takes in list of integers and outputs the list in ascending size.

Now add the following functionality to your program. Each new functionality should be added one at a time, iterating on the initial program.

  1. Program takes in a parameter that determines if the output should be ascending or descending
  2. After each comparison, program outputs whether it resulted in a swap or not
  3. Program outputs how many swaps were done at the end of each complete pass
  4. Program outputs the total number of passes made to complete the sort
  5. Program outputs the total number of swaps done to compete the sort

If you complete that, refactor the program so that it can also take a multidimensional list of dimensions of rectangles (width, height) and output the list in order of area (it should also be able to perform the original functionality with a list of integers).

Is there anything that can be done to improve the performance of the sort?

When you added new functionality were you careful to simplify the code on each iteration?