NAMES:

LOGINS:

PRECEPT:

COS 226 Exercises on Elementary Sorting

References: Section 2.1 in Algorithms, 4th edition


1. Show, in the style of the trace of Algorithm 2.1 (p. 81), 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 2.2 (p. 83), 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 2.3 (p. 91), 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.