Final Exam, CSCI 230, Fall 2020


  1. Abstract Data Type: An abstract data type (ADT) is defined as a data type whose properties(domain and operations) are specified independently of any particular implementation.
    1. [1 point] What is the domain of an ADT?
    2. [1 point] What are the operations of an ADT?
    3. [4 points] Why is it important that the definition of an ADT does not rely on the implementation?
    4. [2 points] What C++ mechanism is used to implment an ADT?.
    5. [4 points] Describe two mechanisms used in C++ to accomplish information hiding.
  2. Classes vs Structures.
    1. [1 point] What is the purpose of a structure in C++?
    2. [2 points] When should a programmer select a structure over a class when implementing a program in C++?
  3. File Processing.
    1. [2 point] Describe the operation of the ifstream member function eof.
    2. [2 point] describe the exact conditions which must occur for the ifstream member function eof to return true.
    3. [6 point] Describe (exactly) the output from the following code if the file input.dat contains the single value 1. Any error in this description will result in loss of points. Explain how the output value was calculated.
      #include <iostream>
      #include <fstream>
      
      using namespace std;
      
      int main() {
      
          ifstream inFile;
          int sum = 0;
          int data;
      
          inFile.open("input.dat");
      
          while(not inFile.eof()) {
              inFile >> data;
              sum += data;
          }
      
          inFile.close();
      
          cout << sum << endl;
      
          return 0;
      } 
  4. Dynamic Memory
    1. [2 points] What does the C++ new operator do?
    2. [2 points] When implementing a class with dynamic memory, why is a destructor required?
    3. When an class object is passed by value
      1. [1 point] what member function is called?
      2. [2 points] What must this member function do?
      3. [2 points] Describe the parameter(s) to this function and how they must be passed.
    4. [2 points] Describe the difference between a deep copy and a shallow copy.
  5. Lists
    1. [4 points] Describe the ADT list. Include all relevant portions from the definition of an ADT.
    2. [2 points] How is a list different from an array?
    3. [6 points] Describe in detail how a list can be implemented in an array.
    4. [4 points] Describe in detail how a list can be implemented as a linked structure.
    5. [2 points] What advantages are gained by implementing a list as a linked structure?

Submission Instructions