CIS 435 DL, Spring 2004
Midterm Exam
Prof. J. Calvin
Print Name (last name first):
This exam consists of 7 pages, numbered 1 through 7. Before starting
to work, make sure that you have all 7 pages. There are six problems,
each counting 20 points. Write all answers on the exam.
During this exam it is prohibited to:
1. exchange information with any other person in any way, including
by talking or exchanging papers or books;
2. use any electronic aid, including calculators;
3. use any books or notes;
4. leave the exam room before you complete and turn in your exam.
I have read and understand all of the instructions above.
On my
honor, I pledge that I have not violated the provisions of the NJIT
Academic Honor Code.
Signature and Date
Stirling’s approximation
:
n
! =
√
2
πn
n
e
n
(1 + Θ(1
/n
))
.
Master Theorem:
The solution
T
(
n
) to the recursion
T
(
n
) =
aT
(
n/b
)+
f
(
n
) can be bounded as follows:
1. If
f
(
n
) =
O
(
n
log
b
a

)
for some
>
0, then
T
(
n
) = Θ
(
n
log
b
a
)
.
2. If
f
(
n
) = Θ
(
n
log
b
a
)
then
T
(
n
) = Θ
(
n
log
b
a
lg
n
)
.
3. If
f
(
n
) = Ω
(
n
log
b
a
+
)
for some
>
0, and if
af
(
n/b
)
≤
cf
(
n
)
for some constant
c <
1 and all sufficiently large
n
, then
T
(
n
) =
Θ (
f
(
n
)).
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
2
1.
Say whether the following statements are true or false. Give a short
explanation (a sentence should do).
a)
The array (13
,
10
,
7
,
9
,
6
,
8) is a maxheap.
It is not a maxheap, since the left child of the node with value 7 has
value 8.
b)
Any algorithm to sort an array of
n
numbers has a running time
that is Ω(
n
).
True. For an algorithm to correctly sort
n
numbers it must at least
read all
n
numbers, which takes time Ω(
n
).
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '09
 ALEX
 Algorithms, LG, lg n lg, lg lg

Click to edit the document details