Final Exam, CSCI 230, Fall 2009


  1. ADT
    1. [3 points] Define Abstract Data Type (ADT)
    2. [8 points] A queue is a common ADT. Describe
      1. The operations on a queue.
      2. The domain of a queue.
      3. The performance expectations of a queue.
    3. [15 points] Stack. Give the implementation for a stack class which employs dynamic memory. Provide both the specification and implementation file.
  2. Dynamic Memory
    1. [2 points] What is a pointer?
    2. [3 points] Why are pointers used?
    3. [2 points each] What do the following operators do?
      1. new
      2. delete
      3. delete[]
    4. [5 points] What rules apply when dealing with a pointer?
    5. [9 points] What member functions must be declared when employing dynamic memory in a class?
    6. [4 points] What is a memory leak and how can this be avoided?
    7. [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.
  3. Linked Lists
    1. [2 points] Describe a linked list.
    2. [8 points] A linked list is an abstract data type. Define/describe the:
      1. Operations on a linked list
      2. Domain of a linked list
      3. Performance expectations of a linked list.
    3. [5 points] Compare and contrast linked lists and arrays. When should each be used?
    4. [5 points] Write a routine which will insert an integer into a linked list of integers.
    5. [5 points] Write a routine which will delete all occurrences of a given integer from a linked list of integers.
    6. [5 points] Write a recursive routine which will take a linked list and print it out in reverse order.
  4. [10 points] Describe how data types can be constructed by a user in C++. Describe why this is important.