[prev] 67 [next]

Application of BSTs: Sets (cont)

Concrete representation:

#include "BSTree.h"

typedef struct SetRep {
   int   nelems;
   Tree  root;
} SetRep;

typedef SetRep *Set;

Set newSet() {
   Set S = malloc(sizeof(SetRep));
   assert(S != NULL);
   S->nelems = 0;
   S->root = newTree();
   return S;
}