CSCI 330 Midterm Fall 2021


  1. Object Oriented Design
    We discussed two distinct items in OODesign: Encapsulation and Abstraction. In the follow answers, demonstrate your expanded understanding of these topics (Do not provide CSCI 230 answers)
    1. [2 points] Define encapsulation
    2. [2 points] Define abstraction
    3. [6 points] You are designing a door for an adventure game. How do the two concepts of encapsulation and abstraction impact your design?
  2. Pointers and Dynamic Memory
    1. [4 points] Define deep copy and shallow copy.
    2. [4 points] Describe the parameter(s) to a copy constructor in a class containing dynamic memory. Explain in detail why the parameter(s) should be declared this way.
    3. [6 points] What is a dangling pointer? How does the overloaded assignment operator in a class containing dynamic memory avoid this problem?
  3. Linked Lists Consider the following definition for a singly linked list.
    struct NodeT {
        int data;
        NodeT * next;
    }; 
    1. [6 points] Write a function which, when passed the head of a properly formed linked list, will delete all of the elements in that list.
    2. [8 points] Write a function which, when passed the head of two properly formed linked lists, will compare the elements of these lists and return true if these lists contain the same elements and false otherwise.
  4. The standard library.
    1. [3 points] Provide code to sort a vector of integers.
    2. [3 points] Write a function which takes a vector of integers and a single integer and returns true if the given integer is in the vector.
  5. Misc
    1. [3 points] Why should a programmer prefer pass by reference and pass by const reference to pass by value?
    2. [3 points] A programmer has provided two versions of a constructor (overloaded), how does the compiler select which version to call?