COP3530Quiz2F99Key - COP 3530 CS3 Fall 1999 14 1. Quiz#2...

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

View Full Document Right Arrow Icon
COP 3530 – CS3 Fall 1999 Quiz#2 Name: Key 14 1. Consider an Abstract Data Type, WaitingQueue ( WQ ), defined by the following protocol public WQ( ) – constructs the WQ with an empty state (no tasks are waiting) public void put(Task t, int p) – adds a new task, t , with priority, p ( p 0 ), to the WQ . There can be many tasks of the same priority. public int max( ) – returns the priority of the highest priority task in the WQ , -1 if there are none. public boolean match(int p) – returns true if there is a task in the WQ whose priority is at least as large as p . public Task deleteHighest() – returns a task in the WQ whose priority is the highest. Returns null if there are no tasks in the WQ . The returned task is deleted from the WQ . public boolean perfectMatch(int p) – returns true if there is a task in the WQ of priority p . public int closestMatch(int p) – returns the priority of a task in the WQ that is as close as possible to p . Returns -1 if there are no tasks in the WQ . public Task deleteClosest(int p) – returns a task in the WQ whose priority is as close as possible to p . Returns null if there are no tasks in the WQ . The returned task is deleted from the WQ . Several abstract implementations (data models) seem appropriate candidates for representing such an ADT. Moreover, each such abstract implementation might need to be evaluated in terms of a specific data structure. Fill in the order of the average complexities in terms of N , the number of elements being stored, of each of the last seven services provided for the WQ ADT, given the following two approaches to implementation. In all cases, assume that individual sizes can be compared in constant time and that you are concerned with expected, not worst-case performance. All orderings are based on task priorities, and duplicate priorities are allowed. i.)The state of the WQ is represented in a Max Heap implementation of a Balanced Priority Ordered Tree ( BPOT ). You may not assume that the heap structure stores any state information other than that provided by the normal heap protocol, plus the ability to treat the heap as a array for purposes of direct access to any element. ii.) The state of the WQ is represented by a Sorted List ( SL ). Assume a simple array data structure, sorted low to high, storing data in positions 0 to N-1 . BPOT
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

COP3530Quiz2F99Key - COP 3530 CS3 Fall 1999 14 1. Quiz#2...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online