NAMES:

LOGINS:

PRECEPTS:

COS 226 Exercises on Elementary Sorting

References: Section 3.1 in Algorithms, 4th edition


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

S E L E C T
Be sure to indicate the value of i and min after each iteration.













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

I N S E R T

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













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

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