Lecture 36 (Tychonievich) - Search and Sort

Lecture Date: Monday, April 13

We listed many kinds of sorting algorithms and implemeted a few:

Bogo Sort
1
2
3
4
5
public static void bogoSort(int[] list) {
  while (isOutOfOrder(list)) {
      shuffle(list);
  }
}

We observed that for lists of just 13 elements, this could take several seconds to run because it’s runtime scales with the factorial of the number of elements in the list.

We also coded mergeSort, but it was big and ugly.

From Lecture