Test II, CSCI 230, Fall 2009


  1. ADT
    1. [2 points] Define Abstract Data Type (ADT)
    2. [3 points] Give an example of an abstract data type. Explain how this example is an ADT.
  2. Array Definition
    1. [2 points] What is an array?
    2. [3 points] What is the difference between an array and a class?
    3. [3 points] Give the syntax for declaring an array.
    4. [2 points] Show how to declare an array of integers.
  3. Array index out of bounds error
    1. [2 points] What is an array index out of bounds error?
    2. [2 point] What are the possible results of an array index out of bounds error.
    3. [2 points] How can an array index out of bounds error be avoided.
  4. Arrays as parameters
    1. [2 points] How are arrays passed as parameters?
    2. [2 points] Why are arrays passes in this manner?
    3. [2 points] How can a procedure implementer guarantee that an array is not changed in a function? Give the syntax to accomplish this.
  5. [10 points] A file contains up to 50 integers. Write a routine which will open the file, read the integers into an array (passed by the user) and return the size of the array. Show all code needed for this routine (the routine, an example call, any pre defined constants, ...)
  6. [10 points] Write a routine which takes an array of characters, and the integer size of that array and returns true if the array is a palindrome. A palindrome is a string that reads the same forward and backward. racecar is an example of a palindrome. The string will only contain lower case letters.
  7. Recursion
    1. [2 points] Define recursion.
    2. [6 points] What is required for a recursive algorithm?
  8. [5 points] Give the algorithm for binary search.
  9. [5 points] Write a recursive routine to calculate xn, where x is a double and n is a non-negative integer.
  10. [5 points] Give an algorithm which will sort an array of n doubles. If your algorithm requires any auxiliary routines, give these as well.