CSC235 Data Structures - Sorting Homework


  1. For the following array X, show X after each of the first two passes of bubble sort to arrange the elements in descending order:



  2. For the following array X, show X after each of the first two passes of selection sort to arrange the elements in ascending order:



  3. The basic operation in the selection sort algorithm is to scan a list X1,…,Xn to locate the largest element and to position it at the end of the list. A variation of this approach is to locate both the smallest and the largest elements while scanning the list and to position them at the beginning and the end of the list respectively. On the next scan this process is repeated for the sublist X2,…,Xn-1, and so on.

    1. Using the array in problem 2 above, show what it would look like after the first two passes of this double ended selection sort.

    2. Write the C++ code or pseudocode to implement this algorithm.

  4. For the following array X, show X after calling split to split the entire array, and show X after calling split again to split each "half". Use the value in the first position as the pivot.


Email Me | Office Hours | My Home Page | Department Home | MCC Home Page