Study Guide...for the Midterm

 

CS 163: Data Structures

 

 

#1)  The midterm will cover Reading Material for Weeks 1-4

#2)  The midterm will also cover the lecture notes.

#3) There will be questions asking you to write functions or classes, to write algorithms, and to figure out what is wrong with a function or class. There will also be a set of short answer.

#4) The exam is closed book and closed notes.

#5)  Topics to study:

The exam will focus on abstract data types: stacks, queues, and ordered lists. Understand both array-based implementations and pointer-based implementations using C++ classes. The following are some topics to study on your own or in a group:

• What is procedural abstraction?

• What are preconditions and postconditions of a function?

• What makes a program modular?  How can modules be specified using C++?

• What is the difference between a header file and an implementation file?

• Review the string.h facilities...

• What is an abstract data type?

• How can an abstract data type be implemented using a class?

• What is the difference between a list, stack, and queue?

• What are the operations that can be done on a stack? on a queue?

• What is an absolute ordered list? a relative ordered list?

• Understand the mechanics of a linked list.

• Understand how to count the number of nodes in a linked list

• Understand how to insert nodes and delete nodes from a linked list

• Understand how to split a linked list in two

• Understand how to concatenate two linked lists

• Understand why dynamic memory allocation is valuable

• What is the major disadvantage of using a pointer-based implementation of a stack versus an array-based implementation?

• Understand how to traverse a circular linked list, delete nodes from a circular linked list, concatenate two circular linked lists, insert nodes into a circular linked list.


 

• Given the following structure, write a function that appends a node to the end of a linked list:

 

struct node {

char * data;

node * next;

};

 

• Using this same structure, write a function to delete the last node in a linked list.

• What are the special cases for deleting a node in a linked list?

• What is the purpose of a destructor and when is it called?

• Why shouldn’t we call a destructor explicitly?

• Write a C++ function that displays only the ith integer in a linked list of integers.

• What are the advantages and disadvantages of using a dynamically allocated array for implementing an ordered list abstract data type?

• What are the benefits and drawbacks of using a linked list, instead?

 

I highly recommend practicing the self-check exercises in the textbook (at the back of each chapter. Also review the two homework assignments as well.