Test II, CSCI 230, Fall 2008


  1. [6 points]
    1. What is an Out-of-bounds indexing error?
    2. Give code that demonstrates this type of error.
    3. What can be the result of an out out-of-bounds error?
  2. [5 points] Define Abstract Data Type (ADT)
  3. [5 points] What is information hiding? How is this supported in C++
  4. [3 points] What is a struct in C++?
  5. [4 points] Explain the difference between defining a struct and declaring a variable that is a struct. Give a code segment example.
  6. [8 points] Compare and contrast structs and arrays.
  7. [5 points] The greatest common divisor (GCD) of two integers can be found using the following algorithm :
    
    gcd(A,B) = A if B = 0
               gcd(B,A mod B)  otherwise.
       
    Write code to find the greatest common divisor of two integers.
  8. [3 points] Show your code in the previous question works by tracing it to find the GCD of 30 and 45.
  9. [3 points] Explain what must be present in any recursive algorithm. Label each of these in your code from the previous question.
  10. [3 points] Show how to declare a two dimensional array of characters.
  11. [5 points] Describe the operation of the new and free operators. What is a pointer? Give example code.