CSE 2320
Name
____________________________________
Test 1
Summer 2006
Last 4 Digits of Student ID #
__________________
Multiple Choice.
Write your answer to the LEFT of each problem.
3 points each
1.
The time to multiply two
n
x
n
matrices is:
A.
Θ
n
( )
B.
Θ
n
log
n
(
)
C.
Θ
n
2
ae
è
ç
ö
ø
÷
D.
Θ
n
3
ae
è
ç
ö
ø
÷
2.
For which of the following sorts does the decision tree model not apply?
A.
Counting
B. Insertion
C.
M
ERGE
S
ORT
D.
Q
UICKSORT
3.
Which of the following sorts is not stable?
A.
H
EAPSORT
B.
Insertion
C. LSD Radix Sort
D. M
ERGE
S
ORT
4.
As
n
approaches
∞
,
H
n
H
2
n
approaches?
A.
1
B.
2
C.
ln
n
D.
n
!
5.
The function
n
+ log
n
is in which set?
A.
Ω
n
log
n
(
)
B.
Θ
log
n
(
)
C.
Θ
n
( )
D.
Θ
n
log
n
(
)
6.
Which of the following expressions corresponds to the time needed for LSD Radix Sort?
A.
Θ
(
d
+
k
+
n
)
B.
Θ
(
d
(
k
+
n
))
C.
Θ
(
k
+
n
)
D.
Θ
(
dkn
)
7.
Suppose a binary search is to be performed on a table with 50 elements.
The maximum number of
elements that could be examined (probes) is:
A.
4
B.
5
C.
6
D.
7
8.
f n
( )
=
n
lg
n
is in all of the following sets, except
A.
Ω
log
n
(
)
B.
Θ
log
n
!
(
)
(
C.
Ο
1
n
(
)
D.
Ο
n
2
ae
è
ç
ö
ø
÷
9.
The expected time for Q
UICKSORT
for
n
keys is in which set?
(All
n
! input permutations are equally
likely.)
A.
Θ
log
n
(
B.
Θ
n
( )
C.
Θ
n
log
n
(
D.
Θ
n
2
ae
è
ç
ö
ø
÷
10.
What is the value of
2
k
k
=0
t
å
?
A.
2
k
B.
2
t
C.
2
t
+1
 1
D.
2
t
11. Suppose that you have correctly determined some
c
and
n
o
to prove that
f n
( )
Î O
g n
( )
(
)
.
Which of
the following is not necessarily true?
A.
c
may be decreased
B.
c
may be increased
C.
n
o
may be increased
D.
g n
( )
Î W
f n
( )
(
)
12. Suppose you are using the substitution method to establish a
Θ
bound on a recurrence
T n
( ) and you
already know that
T n
( )
Î W
n
( ) and
T n
( )
Î O
n
3
ae
è
ç
ö
ø
÷
.
Which of the following cannot be shown as an
improvement?
A.
T n
( )
Î O lg
n
(
)
B.
T n
( )
Î O
n
( )
C.
T n
( )
Î W
n
2
ae
è
ç
ö
ø
÷
D.
T n
( )
Î W
n
3
ae
è
ç
ö
ø
÷
13. Suppose the 201 priorities in a maxheap are unique.
Which of the following subscripts may not store
the minimum?
A.
100
B.
101
C.
199
D.
200
14. Suppose a minheap that can hold
m
records is used to produce sorted subfiles for an external
mergesort.
If the large input file is randomly ordered, the expected number of records in a subfile is:
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentA.
m
B.
2
m
C.
m
ln
m
D.
m
2
15. Which of the following will not be true regarding the decision tree for insertion sort for sorting
n
input
values?
A. Every path from the root to a leaf will have
Ο
n
log
n
(
) decisions.
B. The height of the tree is
Ω
n
log
n
(
).
C. There will be a path from the root to a leaf with
Ω
n
2
ae
è
ç
ö
ø
÷
decisions.
D. There will be
n
! leaves.
Long Answer
1.
Suppose an
int
array
a
contains
m
zeroes followed by
n
ones, where
m
and
n
are unknown.
The size
of the array is given to you as
p
, i.e.
p==m+n
.
Give C code for a binary search to determine
m
in
Ο
log
p
(
) time.
15 points
2.
Use the substitution method to show that
T n
( )
= 3
T
n
3
(
)
+
n
2
is in
Θ
n
2
ae
è
ç
ö
ø
÷
.
10 points
3.
Use the recursiontree method to show that
T n
( )
= 3
T
n
3
(
)
+
n
2
is in
Θ
n
2
ae
è
ç
ö
ø
÷
.
10 points
4.
Show the result after P
ARTITION
manipulates the following subarray.
10 points
3
1
6
9
8
5
7
0
2
4
5.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '12
 BOBWEEMS
 Graph Theory, d., B., c., Adjacency list

Click to edit the document details