COSC 2415 - Data Structures and
ITSE 2445 Data Structures

Bob Comer, Professor of Computer Studies


Exam 1 Review Exercises

Exam 1 will cover Chapters 1-5, and sections 6.1 - 6.3 in Chapter 6. I recommend that you do the following exercises as you study the chapters in the textbook. Answers to the Quick Quiz exercises are in Appendix F at the back of your textbook. Questions marked with an asterisk (*) have answers or additional comments - click here to view them.

The exam will emphasize both C++ coding and concepts. Be sure to review the Summary (Chapter Notes, Programming Pointers, and ADT Tips) at the end of each chapter. Following is a sample question over concepts.

Give a brief description of pass-by-value and pass-by-reference. In what situations should pass-by-value be used? In what situations should pass-by-reference be used?

Chapter 1

Quick Quiz 1.5: 1-2, 4-18.

Other questions and comments

1. How are preconditions and postconditions used? See section 1.1 in the textbook (pages 4 - 6).

2. Overview of C++ - See section 1.3 in the textbook (pages 16 - 30).

Chapter 2

Quick Quiz 2.3: 2-5, 10, 12.

Quick Quiz 2.4: 1-3, 5-15.

Other questions and comments

1. What is a pointer? What does a pointer store? What does it mean to dereference a pointer? See section 2.4 in the textbook (pages 63 - 73).

2. How is the new operator used to dynamically allocate memory? See section 2.4 in the textbook.

3. Know how to use the typedef statement and what it does - See section 2.3 in the textbook (pages 59 - 60).

Chapter 3

Quick Quiz 3.2: 1-10.

Add a question like print array element.

Section 3.3 Multidimensional arrays - I will not cover multidimensional arrays on the exam, but this is interesting material.

Quick Quiz 3.4: 1-8, 10.
I will not cover using function names as parameters on this exam.

Quick Quiz 3.5: 1-8.

Other questions and comments

1.* Given the array declaration:

int list[5] = { 10, 20, 30, 40, 50 };
What is output by this statement?
cout << *(list+2) << endl;

2. What is an ADT? See section 3.2 in the textbook (page 86).

3. What is an array? See section 3.2 in the textbook (page 87).

4. What is the relationship between arrays and pointers? See section 3.2 in the textbook (page 90 - 91).

5. How do we dynamically allocate an array - See section 3.4 in the textbook (pages 107 - 108).

6. How do you use a dynamically allocated array? See section 3.4 in the textbook.

7. How do you free the memory used by a dynamically allocated array - See section 3.4 in the textbook (pages 119 - 121).

Chapter 4

Quick Quiz 4.1: 1-5.

Quick Quiz 4.2: 1-9.

Quick Quiz 4.5: 1-13.

Other questions and comments

1. Know how to write a declaration for a simple class. Why should most data members be private? why should most member functions be public? See section 4.3 in the textbook (pages 152-153).

2. Know how to write basic mutator (set) member functions. Know how to write basic accessor (get) member functions.

3. Know how to write a constructor for a class. You should be able to write multiple constructors for a class - a default constructor (with no parameters) and constructors with parameters. See section 4.4 in the textbook (pages 158 - 162).

4. Know how to overload a "simple" binary operator for a class. See: http://www.austincc.edu/comer/ds10f/binaryop.htm

5. What is the "this" pointer? See the end of section 4.5 (pages 185 - 186).

6. know how the assert() mechanism works. See section 4.3 in the textbook (pages 157 - 158).

Chapter 5

Quick Quiz 5.1: 1-24.

Quick Quiz 5.2: 1-9.

Section 5.4 Pattern Matching - Skip this section.

Section 5.5 Data Encryption - Skip this section.

Other questions and comments

1. know how input and output works in C++ (streams)

2. know some of the basics for using the C++ string class

3. know some of the basics of how to use character arrays (C-strings) to store string data

Chapter 6

Quick Quiz 6.3: 1-16. * Two of the answers in this section are missing, and the rest are mis-numbered, so I have added the answers on the Review 1 Answers page (see above).

Other questions and comments

1. know how to implement a List class using a "static" array (an array declared as a List member). Pay particular attemtion to how the List items are stored in the array.

2. know how to declare a List class using a dynamically-allocated array (a pointer to the array is the List member)

3. know how to write a class descructor function. What is the purpose of a destructor? When is it called? See section 6.3 in the textbook (box on page 277).

4. Every class has a copy constructor. If the class programmer does not write a copy constructor, C++ creates a default copy constructor. What is the purpose of a copy constructor? When is it used (called)? What does a default copy constructor do? When does a class programmer need to write a "customized" copy constructor for a class? See section 6.3 in the textbook (pages 278 - 280).

5. What does the default assignment operator for a class do? When does a class programmer need to write a "customized" assignment operator for a class? See section 6.3 in the textbook (pages 280 - 283).


Return to Data Structures Home Page

Copyright: © 2010 by the Austin Community College
Department of Computer Studies. All rights reserved.
Comments to:
Bob Comer
Last updated: October 5, 2010