2. c) Program correctness can be formalized using a kind of judgment called a Hoare triple
P cfw_ S Q
Where:
P and Q are the pre and post conditions involving the variables in the program
S is the program statement itself
This means that If P is true abo

2. b) This implementation of DFS is a simple loop based algorithm, so as long as the
bounds of the while loop do not increase infinitely the algorithm will definitely
terminate.
Lets now analyze the bounding condition of our while loop and understand if a

1.
c)
Although our previous algorithm was complete and correct, we can improve its running time
by altering its looping constructs and using more complex data structures.
We can do considerably better if we use a priority queue to store the classes. Itll

1.
b)
Let prove that our greedy algorithm returns an optimal set (S) of assignments.
1. S is a compatible set of assignments
We can immediately declare that the assignments in the set S returned by the
algorithm are all compatible, such that there is no o

1.
a)
Initially we have a set of classes C and a set of rooms R. The goal is to build a set of class
to room assignments such that we maximize the number of classes and also maximize the
number of students for any such assignment.
Note that all rooms beco

1. b) Figure 1.b shows the induction step when going from n = 5 to n + 1 (6). The five new
line segments added in this step are dashed and colored red.
The number of new regions introduced by the sixth point can be determined by
considering the number of

1. a) Let,
n be the number of points on the circumference of the circle, and
R(n) denotes the number of regions (inside the circle)
When there is no point on the circle (i.e. n = 0) the entire circle is a single region. So
R(n) = 1
Values of R(n) for n =

2. a) Step 1: Hypothesize a Loop Invariant
At the end of each iteration of the while loop in P(G,s)
count_of_vertices_reachable_from (s) = count + |A|
Where |A| = set of uncounted nodes reachable from
some node on the stack
2
Step 2: Run a few iterations