CIS 121 - Fall 2011
Midterm 2
NAME:
LAB SESSION:
1
2
3
4
5
6
7
15
20
15
10
15
15
10
Sum
100
The depth of a node is the nmber of links on the path from it to the root. The height of the tree is
the maximm depth among its nodes.
1 + q + q 2 + q 3 + . . . +
CIS 121 - Fall 2011
Review for Midterm 1
For code fragments whose running time is a constant, do not give a specic number of steps, use
symbolic constants like c1 , c2 , etc. instead, or O(1).
Use this as known:
1 + q + q 2 + q 3 + . . . + q n1 =
qn 1
.
q
CIS 121 - Fall 2011
SOLUTIONS - Midterm 1
1
(15 Points)
Sort the following running times so that f(n) is left from g(n) if f(n) is O(g(n) indicating whether
any two are to each other. No proof required.
n!, (log n)2 , 7n500 + 2n , n log n, ( 2)n , log(log
CIS 121 - Fall 2011
Review for Midterm 1
For code fragments whose running time is a constant, do not give a specic number of steps, use
symbolic constants like c1 , c2 , etc. instead, or O(1).
Use this as known:
1 + q + q 2 + q 3 + . . . + q n1 =
qn 1
.
q
CIS 121 - Fall 2011
Review for Midterm 1
For code fragments whose running time is a constant, do not give a specic number of steps, use
symbolic constants like c1 , c2 , etc. instead, or O(1).
Use this as known:
1 + q + q 2 + q 3 + . . . + q n1 =
qn 1
.
q
CIS 121 - Fall 2011
Review for Midterm 1
For code fragments whose running time is a constant, do not give a specic number of steps, use
symbolic constants like c1 , c2 , etc. instead, or O(1).
Use this as known:
1 + q + q 2 + q 3 + . . . + q n1 =
qn 1
.
q
CIS 160 - Fall 2012
(instructor Val Tannen)
Mock Midterm 2 SOLUTIONS
Posted Tuesday October 30, 2012
1. (30 pts) For each statement below, decide whether it is true or false. In each case attach a very brief
explanation of your answer.
(a) When proving pr
CIS 121 - Fall 2011 - Practice Quiz - max 50pts
1
(10 Points)
(a) There exist DAGs with two or more vertices which are strongly connected, true or false?
Solution: FALSE. If there are two distinct vertices, u and v, strong connectivity implies there is
di
CIS 121 - Fall 2011 - Practice Quiz - max 50pts
1
(10 Points)
(a) There exist DAGs with two or more vertices which are strongly connected, true or false?
.
(b) A tree can be also regarded as a digraph, with the direction of the edges being always toward
t