Note: This assignment is worth 9% of the course grade. It is due in class on May 3, Late submissions will not be accepted since sketches of the solutions will be handed out. This homework consists of 5 exercises from the text.
Ans: A graph has an Euler path if and only if the graph is connected and there are either 0 or 2 vertices of odd degree. Proof: Part 1. Necessity of the condition: Suppose the graph has an Euler path, (v0, v1, ..., vm). Except for the start at v0 and the finish at vm, every time a vertex v is visited in this path we use two edges, one to get to v and one to depart. Since each edge is used once and only once, every vertex is incident on 2k edges, where k is the number of times v occurs as an interior node of the path. This applies except at v0 and vm which have the one extra edge, hence odd degree. Or they are identical and have even degree.
Part 2. Sufficiency of the condition. Suppose every vertex has even degree or exactly two vertices have odd degree. Let v0 and vm be the two of odd degree if such exist. Let them both be the same and be an arbitrary vertex if all vertices have even degree. Now take a walk starting at v0. Leave a crumb on every edge you traverse and always leave a vertex by way of an edge you haven't previously used. Eventually you may come to a vertex you can't leave. Necessarily this is vm. Now repeat the following until every edge has a crumb: Find a vertex on your walk, vk, from which there is an untraversed edge. Take a walk from vk on un-crumbed edges until it returns you to vk as it necessarily must do (at every other vertex you can get to, you can also get out). Splice this loop into the original path.
Ans: Graph G has a cycle if and only if a back edge is found while constructing a depth first search tree.
A breadth first search tree has no such convenient property. Consider a graph which is a cone on a cycle. The edges are
Ans: run algorithm.
Ans: run algorithm, exploiting the butterfly at each step:
f(a) = fe(a2) + a fo(a2)
f(-a) = fe(a2) - a fo(a2)
and using
1 is square of 1 and -1,
-1 is square of i and -i,
i is square of w and -w,
-i is square of w3 and -w3,
Ans: To compute (a+bi)*(c+di):
Input is (a,b) and (c,d)
x = a*c;
y = (a+b)*(c+d);
z = b*d;
re_part = x - z;
im_part = y - x - z;
return (re_part, im_part)