Pure Programmer
Blue Matrix


Cluster Map

Project: Bubble Sort

The [[Bubble sort]] is perhaps the easiest sort to implement. Write a function that takes a list of integers and sorts the list, in place, using a bubble sort. Test the function by creating a random list of integers, print the random list, sort the list, then print out the sorted list. Accept the number of integers to put in the list and the maximum integer to randomly generate on the command line. What is the worst case performance of the Bubble sort?

Output
$ perl BubbleSort.pl 10 10 "rand" is not exported by the Math::Trig module Can't continue after import errors at BubbleSort.pl line 9. BEGIN failed--compilation aborted at BubbleSort.pl line 9. $ perl BubbleSort.pl 20 100 "rand" is not exported by the Math::Trig module Can't continue after import errors at BubbleSort.pl line 9. BEGIN failed--compilation aborted at BubbleSort.pl line 9.

Solution