581325-0 Data Structures, 1st intermediate exam March 3 2000/AW

Write at the top of each paper the name of the course, the exam date, your name, social security number and your signature. Write each answer on a separate paper!

  1. Describe exactly and graphically what the function classes O(f(n)) mean, and how they can be used to describe the object time of algorithms. How is the time used by an algorithm determined?
                                                                  (9 points)
    
  2. A list is linked in one direction and has no header. A pointer is kept at its beginning and end. The beginning of the list specification is as follows:
       public class List {
    
         private class Element {
           private Comparable data;
           private element link;
         }
    
         private Element start, end;   // beginning and end of list
         private int no;               // number of elements
         ...
    
    Implement the list operations:
                                                                  (8 points)
    
  3. The specification of a binary tree starts thus:
       public class BinTree {
    
         private class Node {
           Object data;
           Solmu left, right;
         }
    
         private Node root;
    
         public BinTree() {
           root = null;
         }
         ...
    
    Into the class, program the methods:
                                                                  (8 points)