Professor Abdul-Quader
Sorting
What do we notice?
More fun: let’s get some volunteers and sort people by height.
The algorithm we used was called the “Bubble Sort” algorithm. It’s called this because the bigger elements “bubble up” to the top at each iteration.
Exercise: Write pseudo-code for the algorithm we described.
Here we describe another algorithm to sort. This algorithm uses the fact that it’s easy to find the smallest element in a list.
Write pseudocode for this algorithm.
Analyze the running times of the two algorithms. Is one better than the other in terms of Big Oh? Fill in the table:
\[ \begin{array}{|c|c|} \hline \text{Algorithm} & \text{Running Time} \\ \hline \text{Bubble Sort} & \\ \hline \text{Selection Sort} & \\ \hline \end{array} \]