**Problem : **
What is the base case for quicksort? How would combining quicksort
with another sorting algorithm like selection sort change the base case?

**Problem : **
How does mergesort achieve its *O*(*nlogn*) efficiency?

**Problem : **
While mergesort and quicksort are two "smart" and efficient sorts,
there are plenty of inefficient sorts out there, none of which you
would ever want to use in a program. One such sort is the permutation
sort. A permutation of a data set is one configuration, one ordering
of the data. If there are *n* data elements in a data set, then there
are *n*! permatuations (you have *n* choices for which element goes
first, then *n* - 1 choices for which element goes second, *n* - 2 choices
for which element goes third, etc, so *n*!). The permutation sort
algorithm computes every permutation of the data set, and for each
one checks to see if it is in order If it is, the algorithm ends. If
not, it continues on to the next permuation. Write permuation sort
recursively (the easiest way to do it). Note that a recursive
algorithm can still have loops.

int sort(int arr[], int n, int i) { int j, flag, swap; int true = 1, false = 0; /* Check to see if list is sorted */ flag = 1; for (j=0; j<n-1; j) { if (arr[j] >= arr[j+1]) { flag = 0; break; } } if (flag) return 1; /* Compute each permutation recursively */ for(j=i+1; j<n; j) { swap = arr[i]; arr[i] = arr[j]; arr[j] = swap; if (sort(arr, n, i+1)) return true; swap = arr[i]; arr[i] = arr[j]; arr[j] = swap; } return false; } void permutationsort(int arr[], int n) { sort(arr, n, 0); }

**Problem : **
Your friend Jane proposes the following algorithm for a sort:

Jane claims that although this algorithm is incredibly inefficient, it will work. You claim that even if you lucked out and got good random swaps, in most cases it would cause your computer program to crash. Why? After every swap, the function will make another recursive call to itself. Due to the incredible number of function calls necessary to get the array into order, the space on the call stack will be exhausted far earlier than a solution could be found.random_sort(data set) { -randomly swap two elements -check to see if the data is in order -if it is return as we're done -otherwise call random_sort }

**Problem : **
Your friend John claims that quicksort has a worst case running time of
*O*(*n*^{2}). Is he right?

Take a Study Break!