CPS 6, Ramm - Summer Semester I - 6/11/99 #16
Chap 8. Arrays, Data, & Random Access
- Redesigning a Word in Context Program
Redesign in Classroom:
context2.cc
- What if File is Too Large?
- Advantage of Vector Class: Resize
-
.SetSize(int size)
member function
- Copying/Cost: Memory and Time
- Double It!
-
.Length()
member function
-
context3.cc
- How to Solve Problem Without Vectors?
- Trailing Variables
- Limited Search
- or Reread File
- Translating Characters to Morse Code
- Translate Table
-
morse.cc
- "CryptoQuotes"
-
transl.cc
A Simple Information Storage/Retrieval System
- Concepts
- Store lines from file in vector
- Retrieve lines by matching substrings
- Like UNIX grep program
-
getinfo.cc
Improving the Storage/Retrieval System
WordList Class
- List of Unique Words
- Update with next word
- Print Unique List
-
allword3.cc
Binary Search
- Telephone Book Analogy
- Requires Sorted Lists
-
| list size | binary search | sequential search
|
| 1 | 1 | 1
|
| 10 | 4 | 10
|
| 1,000 | 11 | 1000
|
| 5,000 | 14 | 5000
|
| 100,000 | 18 | 100,000
|
| 1,000,000 | 21 | 1,000,000
|
-
binsearch
Keeping a Sorted List