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
Quiz # 1
Name:
Key
12
1.
Consider an Abstract Data Type,
IntCollection
(
IC
), defined by the following protocol
public IC( )
– constructs the
IC
with an empty state
public void insert(int x)
– adds a new integer
x
to the
IC
.
Duplicates are allowed.
public boolean hasDuplicates( )
– returns true, if the
IC
contains at least one duplicate, false otherwise.
public int range( )
–
returns an integer that indicates the range in the
IC
, i.e., the difference in values
between the smallest and largest integers stored in the collection.
public boolean find(int x)
– returns true, if the
IC
contains at the value
x
, false otherwise.
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 complexities in terms of
N
, the number of elements being stored, of each of the last four
services provided for the
IC
ADT, given the following six approaches to implementation.
In all cases,
assume that you are concerned with expected, not worst case performance.
You should not be surprised if
one or more of these suggested approaches are poor choices. (Note: Duplicates are allowed.)
i.)The state of the
IC
is represented in a
Min Heap
implementation of a
Balanced Priority Ordered Tree
(
BPOT
).
ii.)
The state of the
IC
is represented as a
Binary Search Tree
(
BST
). Assume a right child / left child
linked list data structure with your only direct access being to the root.
iii.)
The state of the
IC
is represented by a
Hash Table
(
HT
).
You may assume that collisions are handled
by using unsorted buckets and that the hash function evenly distributes the
N
elements over
B
buckets.
Your answer should be in terms of two possibly independent parameters,
N
and
B
.
iv.)
The state of the
IC
is represented by an
Unsorted List
(
UL
).
Assume a simple array data structure,
storing data in positions
0
to
N-1
.
v.)
The state of the
IC
is represented by a
Sorted List
(
SL
).
Assume a simple array data structure, storing
data, smallest to largest, in positions
0
to
N-1
.
vi.)
The state of the
IC
is represented by a
Sorted Linked List
(
SLL
).
Assume a singly linked list data
structure, sorted low to high.
Further assume that we use forward links (lower to higher valued
entries), and that the links are circular (tail points back to head) with a handle to recall the head

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