Fund. CS II (CS152 2004F)

Homework 46: Insertion Sort

Due: 10:00 a.m., Monday, 22 November 2004

Implement the insertion sort method (presumably by writing an InsertionSorter class class that implements Sorter).

The strategy for insertion sort is something like the following:

for i = 1 to length-1
	insert the value at position i in the proper place
		relative to the values at 0 to i-1

The strategy for inserting is something like the following

pos = i
while the thing at position pos is smaller than the thing
at postiion pos-1
	swap the two things
	pos = pos-1

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Wed Dec 8 10:36:58 2004.
The source to the document was last modified on Fri Nov 19 10:34:11 2004.
This document may be found at

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Samuel A. Rebelsky,