CS311 ALGORITHMS
QUIZ 1 - Answer Key
1) (10 pts each) In each of the following functions, indicate whether f = O(g) or f
=(g) or both (in which case f = (g). Prove your results.
Algorithms
Graph representa1on
Alterna1vely, we can use a linked list for each vertex.
Which one is be?er?
Exploring a graph
solid edges -> tree edges
dashed edges -> back edges
Does explore work correctly?
Algorithms
Breadth-rst search
Proceed layer by layer to compute distances
from s to the other ver;ces.
Once we have picked out the nodes at
distance 0,1,2.d the ones at d+1 are easily
determined.
BFS makes su
Algorithms
Hilal Kazan, Fall 2015
Master theorem
Proof
Lets assume that n is a power of b.
Size of the subproblems decreases by a factor
of b with each recursion. It reaches the base
case aGer
Copyright c Sanjoy Dasgupta
1
Note three: Strongly connected components
CSE 101
1 Dening connectivity for directed graphs
Connectivity in undirected graphs is pretty straightforward: a graph that is not connected
can be decomposed in a natural and obviou
Algorithms
Hilal Kazan, Fall 2015
Genera9ng random primes
Genera9ng random primes
Cryptography
Private-key schemes
Alice and Bob meet beforehand and secretly choose a
binary string r of the same length
encryp9on
CS 311
ALGORITHMS HOMEWORK 1
(Deadline is 10th of November, beginning of lecture)
1) (25 pts) Problem 3.4 ii) from the book. Please show the pre and post numbers of
the nodes and explain the steps of the algorithm.
2) (10 pts) Design a linear-time algorit