Assessment Tool

Lecture 16: Sorting

Content Tested:  Insertion Sort (note: this is not presented in lecture)

Lecture Content:

Goals:

Assessment Technique:  Sorting Cards

Purpose:

To allow instructors to find out if students understand insertion sort as another sorting routine.  The instructor must present the insertion sort algorithm to the class.

Activity:

We saw the selection sort algorithm in today's lecture.  Here we will learn a new sorting algorithm.

Four volunteers from the class will be dealt 13 playing cards (normal deck of 52 cards).  Have the students sort their cards from low to high number with 2 being the lowest and ace being the highest card.  They should sort their cards without regard to suit.  The instructor should not ask them to sort in any particular fashion.

When the players have sorted their cards, ask each volunteer how he/she sorted his/her cards.  Some students will probably sort according to insertion sort.  The cards in their hand will be in sorted order.  They'll pick up a new card and place it in the appropriate position.  This placement is similar to the "sliding down" of array elements when using insertion sort on an array of numbers.

The instructor should describe the insertion sort algorithm with code and then perform the algorithm on a hand of cards.

void ins_sort (int b[], int n){
    int num;  /*currently sorting num*/
    int i,j;

    for( j = 1; j < n; j++){
        num = b[j];
        /*insert b[j] into the sorted sequence at the
          appropriate position*/
        i = j - 1;
        while (i >= 0 && b[i] > num){
            b[i + 1] = b[i];    /*move element at b[i]
                                  one position down the array*/
            i = i - 1;
        }
        b[i+1] = num;
    }
}

Note to Instructors

You probably do not need to give students a copy of this exercise.  Instead, just follow the activity outlined above.  It's also important that the students don't get confused with two sorting algorithms.  The instructor might also sort a hand of cards using selection sort just to make the sorting routines distinct.

Possible Uses of Activity: