You are to implement an event counter using red-black tree. Each event has two fields: ID and count, where count is the number of active events with the given ID. The event counter stores only those IDs whose count is > 0. Once a count drops below 1, that ID is removed. Initially, your program must build red-black tree from a sorted list of n events (i.e., n pairs (ID, count) in ascending order of ID) in O(n) time. Your counter should support the following operations in the specified time complexity.
You may implement this assignment in Java or C++. Your program must be compilable and runable on the Thunder CISE server using gcc/g++ or standard JDK. You may access the server using Telnet or SSH client on thunder.cise.ufl.edu.
You must write a makefile document which creates an executable. The names of your executable must be bbst.
Your program has to support redirected input from a file "file-name" which contains the initial sorted list. The command line for this mode is as follows for C++ and Java respectively:
$java bbst file-name
Assume that IDi < IDi+1 where IDi and counti are positive integers and the total count fits in 4-byte integer limits.
Read the commands from the standard input stream and print the output to the standard output stream. Use the command specifications described in part 1 with all lower cases. The command and the arguments are separated by a space, not parenthesis or commas (i.e inrange 3 5 instead of InRange(3, 5) ). At the end of each command, there will be an EOL character. For each command, print the specified output in the table. Use one space if more than one numbers are printed. Print an EOL character at the end of each command.