(Latest Revision: 03/08/2001)
Week 04 Notes for CS 2500, Section 001 -- Spring 2001
CS 2500, Section 001, Monday, March 05, 2001
- Class starts at 10:10. I take roll at 10:20
- Announcement(s)
- Final version of program #1 is due today before midnight -- any
questions?
- Program #2 is due next week, on Wednesday, Mar 14
- Quiz coming up next week, on Friday, Mar 16
- We finish chapter 2 (recursion) in Carrano this week, and read
about C++ in the appendix.
- In Andersen we read about files.
-
- Let's discuss what the inputs and outputs are of the proposed functions
in program #1. Also, what are the preconditions and postconditions?
- Additional discussion of recursion: Write out a "tree" to show how
inefficient it is to calculate (n choose k) with recursion. Also look at
programs nChoose?.cpp. Run them out of the Examples directory to
illustrate how much extra work it can take to compute (n choose k) with
poor use of recursion.
- Discussion of new programming assignment: Asg #02
- Go over the contents of file "gcdAsg"
- Note that the theorem quoted in the assignment is a rule that we
can use to create a recursive algorithm for computing a gcd.
- For example: gcd(m,n) could perform these steps:
- Print message telling what m and n are.
- if m > n, then interchange m and n
- if now m divides n then return m (How do we check whether m
divides n?)
- otherwise return gcd(n%m,m)
-
-
-
CS 2500, Section 001, Wednesday, March 07, 2001
- Look at Upcoming Schedule
- Class starts at 10:10. I take roll at 10:20
- Announcement(s)
- Finish going over the contents of file "gcdAsg"
- Discuss the "Four Questions for Constructing Recursive Solutions"
- How can you define the problem in terms of a smaller problem of
the same type?
- How does each recursive call diminish the size of the problem?
- What instance of the problem can serve as the base case?
- As the problem size diminishes, will you reach the base case?
-
- Discuss structs, classes, arrays of structs, structs containing arrays,
etc.
- Consider the array-based list class (files ListA.h, ListA.cpp,
useList.cpp) as an example of a struct containing an array. Note that
the element type can also be a complex data structure.
-
CS 2500, Section 001, Friday, March 09, 2001
- Look at Upcoming Schedule
- Class starts at 10:10. I take roll at 10:20
- Announcement(s)
- I am finished grading about half the submissions of program #1.
That means the work is a lot more than halfway over. Results will
come out some time over the weekend. I will put grade info in the
web space and I will send results and comments back in individual
e-mails.
-
- Discuss eoln problem being seen with program #1.
- Discuss testing requirements for program #2
- Documentation tip of the day: look at the Kelly-Pohl book and discuss
descriptions of functions as good examples of header comments -- or do
the same thing with the header comments for the listClass functions.
- Finish up with this: Consider the array-based list class
(files ListA.h, ListA.cpp,
useList.cpp) as an example of a struct containing an array. Note that
the element type can also be a complex data structure.
- Discuss virtues of abstract data typing and modular code.
- Easier to design correctly
- Easier to change implementations
- protects integrity of data from users
- Easier to re-use code
- Look at the
data structures talk
-