Monday, May 2, 2011
Bubble Sort
A new method of sorting was learned today. This algorithm is known as Bubble Sort. This algorithm compares pairs of adjacent elements. The number of elements in the array subtract 1 determines the number of passes needed to run through to sort the entire array. When comparing a pair, sometimes a swap is required and sometimes it is not. To make the program more effective, a boolean can be created to check if no swaps are being made to show that the data is already sorted. This sort is useful for the Panther Pantry group to sort their list of items. I have created an array of integers and strings to sort them with bubble sort. This sort is a little different from selection sort.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment