Fundamentals of Computer Science 1 (CS151 2003S)
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[EC]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Lab Writeups]
[Outlines]
[Project]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Scheme Reference]
[Scheme Report]
[CS151 2003S Gum]
[CS151 2002F]
[CS151 History]
[SamR]
Summary: In this lab, we explore a variety of issues related to the insertion sort algorithm.
Contents:
a. Start DrScheme.
b. Copy the code from the accompanying reading into DrScheme.
a. Test both versions of the insert-number
procedure from
the reading by inserting a number
b. What happens if ls
is not in ascending order when
insert-number
is invoked?
Write a new insert-string
procedure that inserts a string into a
list of strings that are in alphabetical order:
> (insert-string "dog" (list "ape" "bear" "cat" "emu" "frog")) ("ape" "bear" "cat" "dog" "emu" "frog")
In case you've forgotten, string<?
and
string-ci<?
are useful predicates for comparing
strings for order.
You may not use the generalized insert
procedure in
writing this procedure.
a. Show how to call the generalized insert
procedure using
lists of strings.
b. Show how to call the generalized insert
procedure using
lists of numbers.
c. Redefine insert-string
so that it uses insert
a. Add calls to the display
and newline
procedures
to the body of the helper in
insertion-sort-numbers
so that it displays the values of
unsorted
and sorted
, appropriately labeled, at each
step of the sorting process.
b. Use the revised insertion-sort-numbers
procedure to sort the values 7, 6, 12, 4, 10, 8, 5, and 1.
Test the insertion-sort-numbers
procedure on some potentially
troublesome arguments:
Document, write, and test a procedure,
(insertion-sort list may-precede?)
.
that generalizes the insertion-sort-numbers
procedure.
http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/History/Labs/insertion-sort.html
.
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[EC]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Lab Writeups]
[Outlines]
[Project]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Scheme Reference]
[Scheme Report]
[CS151 2003S Gum]
[CS151 2002F]
[CS151 History]
[SamR]
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 Tue May 6 09:28:50 2003.
The source to the document was last modified on Thu Apr 24 23:25:44 2003.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2003S/Labs/insertion-sort.html
.
You may wish to
validate this document's HTML
;
;
Check with Bobby