Our computer clock is not continuous. It "ticks" every millisecond and keeps
track of how many ticks have occurred since the beginning of the "epoch"
(Jan 1, 1970). The clocktime does not change between ticks.
Time is continuous, and events (such as interrupts from hardware devices and
the starting of a program) can happen anytime. We have a program that
experiences a sequence of events. At each event in our program, our logic gets
the current clocktime and compares it with the clocktime stored from the
previous event. It outputs either 'D' or 'S' indicating whether the current
clocktime is Different or the Same as the previous event's clocktime. (The first event
after the program starts generates the first 'S' or 'D' based on comparison
with the clocktime at the start of the program.)
Because the first tick during our program can occur anytime within one millisecond after the
start of the program, the string of 'D's and 'S's output from our program
cannot be predicted, even given the exact timing of the program. Create a
class TickTick that contains a method count that is given event, a String[]
of the times of events relative to the start of the program, and returns
the number of different output sequences
that might be generated. The event times are given in milliseconds elapsed
since the start of the program, formatted to contain digits and exactly one
decimal point.
Time is continuous, so exact coincidences do not occur (or occur with probability 0). You should not consider the
possibility that a tick occurs at exactly the same time as an event or at the exact
start of the program. The constraints on event guarantee that two
different events can never be exactly an integral number of
milliseconds apart.
|