COP3530SampleQuiz1Key

# COP3530SampleQuiz1Key - COP 3530 CS3 Fall 1999 6 1. Sample...

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

COP 3530 – CS3 Fall 1999 Sample Quiz # 1 Name: Key 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 BST UL SL put lg N lg N 1 N peek 1 lg N N 1 pop lg N lg N N N 3 2. Describe the concept of encapsulation . The data structures (state representation) and method implementations are hidden. Only the set of services (protocol) is exposed. Changes to data structures and/or method implementations can be made so long as these do not change the semantics of the services. 4

This preview has intentionally blurred sections. Sign up to view the full version.

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

## This document was uploaded on 06/13/2011.

### Page1 / 4

COP3530SampleQuiz1Key - COP 3530 CS3 Fall 1999 6 1. Sample...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online