next up previous
Next: About this document

Computer Programming II (CS2500)

Final Review, Spring, 1997

These are some questions to help you review for the final. They are intended to help you study, but they will not replace studying the book and your notes.

  1. Describe the general problem solving method using a computer.
  2. What are the purposes of comments in a Pascal program?
  3. What is a pointer variable?
  4. Describe the facilities in Pascal for handling pointers.
  5. What is an abstract data type? Give some examples.
  6. Describe the Queue abstract data type.
  7. Give two implementations of the queue ADT.
  8. Describe the Ordered List abstract data type.
  9. Give two implementations of the ordered list ADT.
  10. Describe the Binary Search Tree abstract data type.
  11. Give two implementations of the binary search tree ADT.
  12. How can we estimate the run-time of an algorithm? Give a general description, and some appropriate details.
  13. What is big-Oh? How is it defined, and what (in general) does it mean, and how is it used?
  14. Sort according to ''big oh'':

    displaymath25

  15. Pascal does not include the operation of raising to a power. Therefore, if you want to raise integers to whole number powers, you need to write your own function. As a first attempt, one might write the function:

        function pow (x, n : integer) : integer;
    
             var i, temp : integer;
    
             begin
                  temp := 1;
                  for i := 1 to n do
                       temp := temp * x;
                  pow := temp
             end

    What is the approximate runtime of this function?

  16. What will the output of the following program be? What is the approximate runtime of the function `mystery' (in terms of y)?

          Program pow(output);
          function mystery(x, y : integer):integer
             var tmp : integer;
             begin if (y = 0) then mystery := 1
                else if (y = 1) then mystery := x
                else begin tmp := mystery(x, y div 2);
                   if ((y mod 2) = 0) then mystery := tmp * tmp
                   else mystery := tmp * tmp * x
                end end;             
          begin writeln('mystery(5,0) = ', mystery(5,0));
             writeln('mystery(7,1) = ', mystery(7,1));
             writeln('mystery(2,5) = ', mystery(2,5)) end.
  17. What is a recursive function?
  18. Given some Pascal code, describe its output for given input.
  19. Write some Pascal code.
  20. Etc. ...





Tom Carter
Mon May 19 20:43:49 PDT 1997