Final Exam, CSCI 230, Spring 2011


  1. [6 points] What are data encapsulation and data hiding? Why are these techniques employed?

  2. [12 points] Describe ADT queue. Include a description of the domain, operations and performance expectations.

  3. [12 points] Describe the member functions which should be included with any class containing dynamic memory. Discuss why each should be present.

  4. [6 points] Describe how memory can be allocated at run time. Give a c++ example.

  5. [4 points] Describe how dynamic memory is disposed of. Give a c++ example.

  6. [4 points] Why would a programmer employ dynamic memory?

  7. [4 points] Describe two common errors associated with dynamic memory.

  8. [6 points] What is a linked list? How is a linked list different from an array?

  9. [20 points] Declare and implement a c++ class which contains an unordered linked list. Include member functions to insert, delete, and locate an item in the list.

  10. [10 points] Write a recursive c++ binary search routine. The routine should take an array of integers, the position from which to start searching and the position where the search ends.

     

     

    OVER

     

  11. [10 points] Given an implementation of an integer stack, which includes Push, Pop, and Top, trace the execution of the following code:
     stackT S,T;
     int i;
    
     for(i=0;i<7;i++) {
         S.push(i);
     }
    
     while(!S.IsEmpty()) {
        T.push(S.top());
        S.pop();
        if(!S.IsEmpty()) {
            S.pop();
        }
     }
     while(!T.IsEmpty()) {
        S.push(T.top());
        T.pop()
     }
     
      
  12. [6 points] What is function/operator overloading? Describe how this technique is useful. Give an example in c++