COMP225 Practical Exercises

Week 3

  1. * In the class BST discussed in lectures implement a recursive definition for
     void BST::InsertItem ( ptrType &TreePtr, int NewItem, bool &success);
     

    Test it using the test function (defined in main) in the file BST.cpp. [Hint: understanding how to do this may help you with Assignment 1.)

  2. Find and fix the bugs in the following program.
          int binarySearch {char A[], first, last, char key}
            {  if (first+1 >= last) return first;
               else{
               int mid= (first+last)/2;
               if (A[mid] <= key) return binarySearch(A, mid, last, key);
               else   return binarySearch(A, first, mid, key);
               }
            }
     

All enquiries to Annabelle McIver