Test II, CSCI 230, Spring 2022


  1. ADT
    1. [2 points] Give the definition for ADT.
    2. [3 points] This definition consists of three parts. Name and explain each.
  2. Structures
    1. [2 points] What is a structure?
    2. [3 points] Give the syntax for declaring a structure in c++.
    3. [2 points] Why would a programmer pass an structure by constant reference?
  3. Arrays
    1. [2 points] What is an array?
    2. [3 points] Give the syntax for declaring an array in c++.
    3. [2 points] By default, how are arrays passed to functions?
    4. [2 points] Why would a programmer pass an array by constant value?
    5. [4 points] In our programs we stored bot the capacity and size of an array. What is the difference between these two values? What is the reason for each?
  4. An algorithm is said to be $O(n^2)$.
    1. [1 point] What is n?
    2. [2 points] What does this say about the performance of the algorithm?
    3. [2 points] Name an algorithm that has this performance characteristic.
  5. Programming
    1. [10 points] Write a function which takes an array of integers, the size of that array and an integer value. This function should return the number of times the integer value appears in the array.
    2. [10 points] Write a function which takes an array of strings and the number of strings in the array and reverses the order of the elements in the array. Since the array may be quite large, do not make a copy of the array.
      If the array contains
      "now""is""the""time
      After the function is called the array should contain
      "time""the""is""now