Review for Test 2
The test will be held in class on Monday, May 22 and will be
closed-book. Bring only a pen or pencil and an eraser. The test will
consist of 4 pages, the first of which you will tear off and use as a
reference sheet.
Coverage will include material in Chapters 10 and 12 of text and
supplementary material on linked lists, stacks, and queues. When
studying for the exam carefully look over:
(1) Notes you've taken from class (emphasis on material covered after
Test 1)
(2) Textbook (Chapters 10 and 12)
(3) Programming Assignments (emphasis on Programs 3 and 4)
The following is a list of the major topics you should know.
Searching a list
- Sequential Search
- Binary Search
see recursive code given on this website.
see non-recursive code given in the text.
precondition is that list is sorted.
- Comparison of computing times of Sequential Search and Binary Search,
i.e., for a list of size n Linear Search requires n comparisons in the
worst case, whereas Binary Search requires about log2 n
comparisons in the worst case. This is the efficiency gained by dividing the list in
half with each comparison.
Two-dimensional vectors
- Exploring a two-dimensional list (see section 10.10 of text)
- Resizing and Intializing a 2-dimensional vector
- Implementing a table (see example in section 10.10)
- Adjacency matrix implementation of a network using
a two-dimensional vector
- Distance matrix of a network using
a two-dimensional vector
Pointers
- Definition of a pointer object
- Declaring pointer variables, null pointer
- Indirection, indirection (or dereferencing operator) *
- Addressing, address operator &
Dynamic objects
- definition
- new operator
- delete operator
- implementing a linked list
- constructors and destructors
- issue of copying and assignment
Pointers Pitfalls
-Memory Leaks
-Unintended aliasing
-Dangling pointers
-Difficulties in programming and debugging
Stacks (LIFO Lists)
- Definition
- Implementation using linked lists (given in this website)
- Utilization in a client program (sample given in this website)
Queues (FIFO Lists)
- Definition
- Implementation using linked lists (see Program 4)
- Utilization in a client program (see Program 4)