This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up**This preview shows
pages
1–2. Sign up
to
view the full content.*

COP 3530 – CS3 Fall 1999
Sample Quiz # 1
Name:
6
1.
Consider an Abstract Data Type,
EventQueue
(
EQ
), defined by the following protocol
public EventQueue( )
– constructs the
EQ
with an empty state (no upcoming events)
public void put(int t, Event ev)
– adds a new event,
ev
, scheduled to occur at time,
t
, to the
EQ
.
Multiple
events can occur at the same time.
public Event peek( )
– returns an event with the smallest time value of all events in the
EQ
.
Null is returned
if the queue is empty.
This does not change the
EQ
.
public Event pop( )
– pops an event with the smallest time value of all events from the
EQ
. Null is returned
if the queue is empty.
This changes the
EQ
.
Fill in the order of complexities in terms of
N
, the number of events being stored, of each of the three services
provided for the
EQ
ADT, given the following four approaches to implementation.
In all cases, assume that
you are concerned with average, not worst case performance.
i.)The state of the
EQ
is represented as a
Balanced Priority Ordered Tree
(
BPOT
).
Here we store the
minimum time value, not the maximum at the root of each subtree.
You should assume a
Min
Heap
data structure is used.
ii.)
The state of the
EQ
is represented by a
BST
, the time serving as the sort key. Assume a right child /
left child linked list data structure.
iii.)
The state of the
EQ
is represented by an
Unsorted List
(
UL
).
Assume a simple array data structure
that stores the
N
events unsorted in positions
0
to
N-1
.
iv.)
The state of the
EQ
is represented by a
Sorted List
(
SL
).
Assume a simple array data structure that
stores the
N
events in positions
0
to
N-1
, sorted low to high by time.
BPOT

This
** preview**
has intentionally

This is the end of the preview. Sign up
to
access the rest of the document.

Ask a homework question
- tutors are online