Data Structures
Review sheet for first midterm, 2004Mar18

Kinds of questions:

  • Multiple choice
  • short answer about a concept
  • short answer about a code fragment
  • write (short) code

    Topics;

  • chapter 1 - C++ review
  • words/wordcount.cc - illustrates basic C++
  • words/wordfreq.cc - illustrates use of map
  • isprime.cc illustrates template function
  • Chapter 2 - card game as example of class use
  • HW1 - card game as example of separate compilation of class definition and class application (both using class declaration)
  • protecting the headers from multiple inclusions.
  • independent evolution of class definition and class application, both honoring the interface determined by the class declaration.
  • File types (.h, .cc or .C, .o, executable files, and Makefile) - what kind of thing is in each.
  • The make utility - Makefile and it's format
    "term = ... " // on using line: "$(term)"
    "target: dependencies \n\t action"
  • Chapter 6 - summary of data structures, their basic differences
    string, vector, list, stack, queue, deque, set, map
  • Chapter 7 - strings
  • words/chartypes.cc - std functions to recognize letters, digits, punct, ...
  • palindrome - illustrations use of string functions and generic algorithms (transform)
  • string implementation - direct and as extension of vector
  • The tar utility - c-reation, t-able of contents, x-traction
    tar cvf foo.tar foo/
  • iterators - how they basically have the same operators and semantics as pointers - how containers provide begin() and end() returning iterators.
  • Chapter 8 - vectors
  • maxmin.cc - example of using vector basic functions, also compare and contrast use of iterators (*p, p++, p < A.end() ) vs use of indices (A[i], i++, i < ? ).
  • stringy, string implementation as extension of vector
  • Sieve of eristosthenes - example using vector
  • Merge sort
    - example of recursive algorithm
    - example of template generic function
    - example of concept use. A "concept" is an interface.

    Sample questions

    1. Iterators are most like

      A. function objects.

      B. structs.

      C. loops.

      D. pointers.

      Ans: D.

    2. Which of the following is not a standard operation on iterator p?

      A. ++p

      B. p()

      C. *p

      D. p->x

      Ans: B. It's not a function object.

    3. Which is created by this command:
      g++ X.cc -c

      A. A relocatable (.o) file

      B. An executable file not named a.out

      C. An executable file named a.out

      D. none of the above

      Ans: A.

    4. Which is created by this command:
      g++ X.cc -o X

      A. A relocatable (.o) file

      B. An executable file not named a.out

      C. An executable file named a.out

      D. The command is syntactically incorrect.

      Ans: B.

    5. Which is created by this command:
      g++ X.o A.o B.o -R/opt/gcc-3.2/lib

      A. A relocatable (.o) file

      B. An executable file not named a.out

      C. An executable file named a.out

      D. The command is syntactically incorrect.

      Ans: C.

    6. What are the arguments to the algorithm std::transform, and what does it do?

    7. Write m_sort //to sort a range in place using the merge sort strategy.

    8. Write palindrome type 2. // to determine if a range contains an exact palindrome when you ignore upper/lower case distinction on letters.