Unit V: Sorting and searching
Lecture notes
- Notes for class V.1: More Control Structures and some sorting
- Notes for class V.2: Sorting algorithms
- There were no notes for class V.3.
- Notes for class V.4: Searching
Sample Programs
- Here are the programs files.cpp, files2.cpp, and files3.cpp, which give many of the
file handling examples from class V.1.
- Here also are the files numbers.txt and numbers-short.txt with which to test those programs.
- Further, we have sort.cpp,
which includes code for the various sorting algorithms discussed in
class V.1 and class V.2.
- From class V.4 we have search.cpp, which has code for the
search algorithms we discussed, lots-of-numbers.txt,
which is a largish list of numbers to test the search algorithms with,
and ga.cpp, which is the code for the
genetic algorithm I showed you.
Reading
The do/while and switch control structures are in
Chapter 9, of the textbook, pages 228 to 229.
Sorting and searching aren't really covered in much detail in the
textbook, but insertion sort pops up on pages 149-153.
As ever, the material is a little different from what we looked at in
class, but all of it is relevant. Don't skip stuff just because
I didn't mention it.