CS 240: Algorithms and Data Structures
James Madison University, Fall 2024

Introduction

For these sorting exercises, one person will play the role of the computer, and one person will play the role of the algorithm. Only the computer should have access to this sheet.

The person playing the computer will first lay out the cards face down following the provided template.

Once sorting begins, the person playing the algorithm will follow the steps of the provided code. Any time the code calls for a comparison, the algorithm will ask the computer to perform that comparison and report the result. Any time that the code calls for a swap, the algorithm will ask the computer to perform the swap. These are the ONLY two operations that the algorithm can request of the computer. The algorithm is never allowed to view the cards directly. Once the algorithm terminates, flip the cards face up to check the result of the sort.

Insertion Sort

Selection Sort

Comparing Sorts