Lecture #16
- Announce
- Continue to Read Chapter 4
Top-Down Programming, Subroutines, & a Database Application
- Information Retrieval
- "Parallel" Arrays or "Corresponding" Arrays
- Model Phone Book Capability
- Array (of strings) for Names
- Array (of strings) for Phone Number
- Array (of strings) for Address
- Typical Access by Name
- For human use, ordered by name to speed access
- For computer use, may be fast enough for non ordered access
- Access by other Fields (other arrays)
- Can access by phone number and get name/address
- (like "phone -p 660-6532" on acpub system)
- Implementing a "Phone List" Using Two Arrays
LookUp.java, LookUp.html
- Implementing a "Phone List" in a Single Array
Search.java, Search.html
- Extend Idea to Database
- Generalization of phone book problem
- Can have many "parallel" arrays
- Basic Data Base Functions
- Load Data (File I/O would be nice)
- Display Data (Complete Dump)
- Query/Search (Selective Info Retrieval)
- Edit/Update (Update or Correct: Edit Database)
- Wild Card Retrieval
- Allows query to say "I don't care" for certain fields
- Used Car Database
UsedCars.java, UsedCars.html
- Other Possible Commands
- output counts rather than displaying data
- logical expressions
- for numeric data give ranges
- Relational Data Bases
- Example: Personnel Database
- Employees
- Departments
- Job Descriptions
- Recursion
- Function invokes itself
- Dictionary Lookup Model
- Factorial (N!)
- decomposing problem
- base case
- recursive case which gets closer to solution
- Factorial
RecFact.java, RecFact.html
- Iterative Approach for Factorial