Answers Exam 3
Answers Exam 3
11 December 2013
1. What is the private key data for the RSA cryptosystem? What is the
public key data? How are messages encrypted using this data? How
are messages decrypted?
The private key consists of data p, q, φ, b and the public key consists of
data a, n where
1
2. What is an eulerian walk? State Euler’s Theorem on the existence of
eulerian walks. How is it proved?
An eulerian walk is a walk v0 , v1 , . . . , v` (meaning that each pair vi , vi+1
are the endpoints of an edge) such that each edge of the graph is tra-
versed exactly once. Euler’s Theorem says that a connected graph (or
even multigraph) contains an eulerian walk if and only if the number
of nodes of odd degree is 0 or 2. This is proved using these facts:
Together with the fact that every graph contains an even number of
nodes of odd degree these facts imply the “necessity” half of the charac-
terization. For the “sufficiency” half we build an algorithm. If there are
nodes of odd degree choose one; otherwise choose any node. From the
chosen node begin a walk which avoids repetition of edges. Continue
until you reach a node node where all edges have been traversed. Then
go back to the beginning of the walk and examine each node in order,
splicing in closed walks along edges not yet traversed. Eventually all
edges will be included.
2
4. What is a spanning tree in a graph G? Describe two methods for
finding a spanning tree.
A spanning tree is a subgraph with the same nodes as G and which
is a tree. One way to construct a spanning tree is to successively
choose nodes and edges from G subject only to the restriction that
you never create a cycle from the set of edges chosen. Eventually
you obtain a maximally acyclic subgraph, which must be a spanning
tree. Alternatively you can successively delete edges from G so long
as you never disconnect the graph. Eventually you obtain a minimally
connected subgraph, which must be also be a spanning tree.
3
Computations
You must show all your work in order to receive credit for your solutions.
4
So, the walk around T is
5
7. Let E be the elliptic curve y 2 = x3 − 7x, with the point at infinity
serving as the identity for its group law. Graph E and on it locate the
points P = (4, 6) and Q = (0, 0). Compute 2P and P + Q. Illustrate
your solution.
To graph E we first graph the cubic y = x3 − 7x, which has 3 distinct
real roots, and then take “square roots” of the y-values:
Now let’s write down the formulas for the coordinates of the addition
of points P1 and P2 . We suppose that the line joining them is the
tangent line in case P1 = P2 , and that in any case the line is not
vertical. (Otherwise P1 + P2 = O, the point at infinity.) Let us say
that P3 = P1 + P2 and Pi = (xi , yi ) for each i. If the line joining P1
and P2 has equation y = mx + b then the xi all satisfy the equation
m2 x2 + 2mbx + b2 = x3 − 7x.
Hence
m2 = x1 + x2 + x3 ,
6
or
x3 = m2 − x1 − x2 .
Now let’s apply our formulas in the case P1 = (4, 6) and P2 = (0, 0).
The equation of the secant line is
3
y= x
2
whence the x-coordinate of P + Q is
9 7
−4=−
4 4
and the y-coordinate is
3 7 21
−− · = .
2 4 8
7
Proofs
In this section all graphs are simple — that is, they have no multiple edges
and no self loops.
9. Suppose that T is a rooted tree. Prove that if the root has degree d
then T has at least d leaves.
We prove this by induction on the number of nodes. If T consists of a
single node then d = 0 and indeed T has at least 0 leaves. Now suppose
that T has more than one node. Let r denote the root. If from T we
delete r and all the edges on it then the connected components of this
smaller graph are called the branches of T at r. Each of these branches
is a tree in its own right. Note that since T is a tree r is connected to
exactly one node in each branch. Indeed, if r were connected to two
nodes in a branch then the unique path joining them in the branch
together with the edges joining the ends of the path to r would form a
cycle in T . Let us root each of these trees at its unique node joined to r.
If a branch consists of a single node then it is a leaf in T . Otherwise the
root of that branch has degree at least 1, and so by induction contains
at least 1 leaf. By definition this leaf is not the root of that branch. By
our previous remarks this leaf is not joined to r in T , hence its degree
in T is also 1. That is, it is a leaf in T . Thus each of the d branches
contains at least 1 leaf in T , as required.
8
Python
10. The following is a python function for depth-first search (DFS). Modify
the code so that it returns a pair T,C where T is a spanning tree and C
is a planar code of T.
def DFS(G,r):
T = graph()
T.add_node(r)
V = [r]
while V:
x = V[-1]
U = [y for y in G[x] if y not in T]
if U:
y = U[0]
T.add_node(y)
T.add_edge(x,y)
V.append(y)
else:
V.pop()
return T
def augmented_DFS(G,r):
T = graph()
T.add_node(r)
V = [r]
C = []
while V:
x = V[-1]
U = [y for y in G[x] if y not in T]
if U:
y = U[0]
T.add_node(y)
9
T.add_edge(x,y)
V.append(y)
C.append(1)
else:
V.pop()
C.append(0)
C.pop() # 0 should not be appended
# when we examine the root r
# the very last time
return T, C
11. Provide a big-O analysis of the running time of the DFS code above.
The main loop iterates over each edge exactly twice: once downward
and once upward. The critical calculation in iteration is
This examines the children of the current node x and determines which
of these (if any) have not yet been visited. The number of nodes to
check is bounded by the number of nodes in T, which in turn is at most
the number of nodes in G, of course. We could provide a sharper bound,
especially if we wanted an analysis of the average running time, but we
are only asked for a big-O analysis, so this estimate suffices. Thus we
can say that the number of basic graph operations performed is
O(|E| · |V |) = O(|V |3 ).
10