previous | start | next

A Symbol Table Implementation

SequentialSearchST

SequentialSearchST from the text is a class that implements the symbol table methods by storing (key, value) pairs in an unordered linked list.

The Node class used for building the linked list contain members for the key and for the value in addition to links to the next (and possibly the previous) Node.

BinarySearchST

BinarySearchST is another class in the text that also implements the symbol table methods by storing the (key, value) pairs in two arrays - one for the keys and one for the values.

      Key[] keys;
      Value[] values;
   

These two arrays are logically related through the array indices: the key at keys[i] has corresponding value values[i].

The keys array is kept in sorted order!

This means the Key type must implement Comparable.

Instead of using equals method to search for keys, the compareTo method is used.



previous | start | next