OO Programming and Data Structures | CS 241

10 Prepare : Checkpoint B - Insertion Sort

After completing (or while completing) the preparation material for this week, complete the following exercise.

Overview

This checkpoint is intended to help you practice the syntax of a basic sorting algorithm.

Instructions

For this assignment, you need to implement an insertion sort and use it to sort an array of integers.

This assignment is identical to checkpoint A with the exception that you should implement a different sorting algorithm.

  1. Begin with this template file: sorting.py

  2. Functions are provided for you that prompt the user for a list, pass it to a function to be sorted, and finally display it.

  3. Your task is to fill in the body of the sort function.

  4. Please note that the reading assignment for this week contains the actual code for this algorithm. You should not simply copy and paste this (or copy it down directly by typing it in). Instead, first gain an understanding of the algorithm, then try to implement it based on your understanding. If you get stuck, you can go look at the reading again, try to understand the approach, then close it, and go back to your code.

Testbed

An auto-grading testbed script is provided for you to help evaluate your program. This same testbed script will be used to grade your program. It is pass/fail, so your program must pass the testbed completely for you to receive credit for this assignment. You may run the testbed as many times as you like.

Please note that it is possible to do this assignment without using one of these sorts, but this will not help you understand the concept, and you will not receive credit if you do not follow the instructions.

Helpful commands


testBed cs241/check10b check10b.py
submit check10b.py