Final Exam, CSCI 230, Fall 2009
- The weight for each question is given with the question.
- Use as much paper as you wish, but make your answers are legible.
- Please answer each question thoughtfully and carefully.
- ADT
- [3 points] Define Abstract Data Type (ADT)
- [8 points] A queue is a common ADT. Describe
- The operations on a queue.
- The domain of a queue.
- The performance expectations of a queue.
- [15 points] Stack. Give the implementation for a stack class which
employs dynamic memory. Provide both the specification
and implementation file.
- Dynamic Memory
- [2 points] What is a pointer?
- [3 points] Why are pointers used?
- [2 points each] What do the following operators do?
- new
- delete
- delete[]
- [5 points] What rules apply when dealing with a pointer?
- [9 points] What member functions must be declared when employing dynamic memory in a class?
- [4 points] What is a memory leak and how can this be avoided?
- [5 points] Write a routine which takes an integer arraySize and an integer pointer newArray. This routine should allocate arraySize integers and point newArray at this newly allocated memory.
- Linked Lists
- [2 points] Describe a linked list.
- [8 points] A linked list is an abstract data type. Define/describe the:
- Operations on a linked list
- Domain of a linked list
- Performance expectations of a linked list.
- [5 points] Compare and contrast linked lists and arrays. When should each be used?
- [5 points] Write a routine which will insert an integer into a
linked list of integers.
- [5 points] Write a routine which will delete all occurrences of a given integer from a linked list of integers.
- [5 points] Write a recursive routine which will take a linked list and print it out in reverse order.
- [10 points] Describe how data types can be constructed by a user in C++. Describe why this is important.