COSC 2415 - Data Structures and
ITSE 2445
Data Structures
Bob Comer, Professor of Computer
Studies
Exam 1 Review Exercises
I recommend that you do the following exercises as you study the chapters in the textbook. Answers to these Self-Test Exercises are at the end of each chapter in the textbook. I have added additional comments to the exercises that are marked with an asterisk. Click here to review my comments.
The exam will emphasize both C++ coding and concepts. Be sure to review the Programming Tips, C++ Feature, and Pitfall sections that are scattered through the chapters. 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 5
Self-Test Exercises: 1,2,3,4,5,6,7,8,9*,10,11,12,13,14,15,16,17*,18,20, 21*,22,26,28,29,30,33,34,35,41,42,43*,44.
Other Questions:
1. Rewrite your answer to Self-Test question 17 using only node member functions (do not use any of the non-member functions in the toolkit).
Chapter 6
Self-Test Exercises: 1,2,3,4,5*,6,8,9*,10,11*,12,13,15,16,19,20,21,22,25,29,33,34.
Note: I want you to understand how to use an iterator, but I will not ask you
to write an iterator for a class on the exam.
Other Questions:
1. A class that contains a pointer to an object of the same class is called a self-referential class. Give an example of a self-referential class.
2. Write the declaration for a class called my_node that has 2 public data members - an int called data and a pointer to my_node called next.
3. Write C++ code to declare an object of type my_node from question 2 and set its data field to 5 and its pointer files to NULL.
4. Given only the pointer (named current) to a node in a singly-linked list (not the first node), can you write code to delete the node? See the picture below.
+---+---+ +---+---+ +---+---+ +---+---+ --> | 2 | --+---> | 4 | --+---> | 6 | --+---> | 8 | --+---> +---+---+ +---+---+ +---+---+ +---+---+ ^ | current
Chapter 7
Self-Test Exercises: 1,2,3,4,5,6,7,9,10,11,12,15,16*,17,18.
Chapter 8
Self-Test Exercises: 1,2,3,4,5,6,7,10,17,18,19,20,21,23,24,25.
Return to Data Structures Home Page
Copyright: Ó 2006 by the Austin
Community College
Department of Computer Studies. All rights reserved.
Comments to: Bob
Comer
Last updated: October 10, 2005