NAMES:

LOGINS:

PRECEPT:

COS 226 Exercises on Elementary Sorting

Reference: Section 2.1 in Algorithms, 4th edition


1. Show, in the style of the trace of Algorithm 2.1 ( p. 155 ), the result of using selection sort to sort the keys:

S O R T I T
Be sure to indicate the value of i and min after each iteration.













2. Show, in the style of the trace of Algorithm 2.2 ( p. 157 ), the result of using insertion sort to sort the keys:

S O R T I T

Be sure to indicate the value of i and j after each iteration.













3. Show, in the style of the trace of Algorithm 2.3 ( p. 165 ), the result of using shellsort to sort the keys:

N O T H A R D T O S H E L L S O R T
Be sure to give the value of h used in each step.