NAMES:

LOGINS:

PRECEPTS:

COS 226 Exercises on String Sort


References: Section 5.1 in Algorithms, 4th edition

1. Sort the 16 names below using LSD string sort (Algorithm 5.1) in the book. Show the result (by listing the 16 full words) of each of the four stages of the sort.

Stage 0          Stage 1          Stage 2          Stage 3          Stage 4
-------          -------          -------          -------          -------

John

Josh

Alex

Eric

Dave

Gene

Ting

Ryan

Jose

Jack

Noah

Luke

Gina

Theo

Will

Anna






2. Show the contents of the array after one partitioning step in 3-way string quicksort (Algorithm 5.3) of the following 16 names. Be sure to use the 3-way partitioning scheme in Algorithm 5.3.

                 After partitioning
Input            on the J in John
-------          ------------------

John

Josh

Alex

Eric

Dave

Gene

Ting

Ryan

Jose

Jack

Noah

Luke

Gina

Theo

Will

Anna