-


> > > > Programming Assignments > Assignment #5 - BST of Intervals

Objectives

Introduction

The Integer-Set-With-Next-Excluded ADT is an ADT with the usual set operations add, remove, contains, and size, along with new operations count-intervals, which determines the minimum number of complete intervals the integers in a set can be divided into, and next-excluded, which, given an integer x returns the smallest integer greater than or equal to x that is not in the set.

Assignment

Complete the implementation of the functions in isset.h to implement the Integer-Set-With-Next-Excluded ADT using some variant of a balanced binary search tree. "Balanced" can mean "approximately balanced" or "balanced enough often enough" as long as any sequence of $k$ add, remove, contains, and/or next-excluded operations starting on an empty set takes total time $O(k \log k)$ for large enough $k$ (so the efficiency requirement will be met if each operation takes time $O(\log n)$ in the worst case or if each operation takes amortized time $O(\log n)$ where $n$ is the number of integers currently in the set). The size and count-intervals operations should take $\Theta(1)$ time.

The provided header file isset.h and your implementation file isset.c must be the only files needed to use your implementation of the ADT.

If the input is not as specified or testable preconditions to the ADT functions are violated then your program must behave gracefully – it must not crash or go into an infinite loop.

Your program and any program that uses your implementation correctly must not produce any error messages when run with valgrind --tool=memcheck --leak-check=yes -q.

If you choose to implement a splay tree, you may cast away the const qualifier where necessary to account for the logical-but-not-physical-const-ness of some of the isset functions.

We reserve the right to deduct points from submissions for violations of the following guidelines.

Files and Submissions

Files are available in /home/httpd/html/zoo/classes/cs223/f2017/Assignments/ISSet:

Submit your isset.c, the provided isset.h, isset_test.c, and a makefile that produces an executable called Test from isset_test.c.


Valid HTML 4.01 Transitional