b) Using depth-first search, it may be that a solution is never found. For example, if every node has at least one child, the search will inspect only one node at each level. Since level s may have more than one node, the solution node may not be that node at level s which is inspected.
c) In perhaps the most natural implementation, after a node is inspected and rejected, its children are enqueued. In this case, when inspecting a node N on level k, the queue will contains the nodes to the right of N on level k, and to the left of N on level k+1. In this worst case, k=s, and the queue size is Θ(ms+1). This can be reduced to Θ(ms) if the rejected node itself is placed in the queue.
d) The stack holds a path from the root to the current node. Since in general the current node can be arbitrarily far from the root, there is no upper bound on the stack size.
e) This case differs from (c) since we may assume that nodes at level s have no children. So the worst case is when the solution node is the leftmost node at level s. In this case the queue size will be Θ(ms).
f) The worst-case stack size is the length of the longest path from a root to a node, which is Θ(s).
Note that if we fix m, ms+1 is Θ(ms).
b) Assuming a function LeftShift(x,m) that shifts x m bits to the left, one pseudocode version of the algorithm is
Multiply(r, s)
if length(r) = 1 then
return rs
else
let a be the high order n/2 bits of r
let b be the low order n/2 bits of r
let c be the high order n/2 bits of s
let d be the low order n/2 bits of s
let j = Multiply(a,c)
let k = Multiply(b,d)
return
LeftShift(j,n) + LeftShift(Multiply((a+b),(c+d))-j-k], n/2) + k
Note that LeftShift does not actually perform any multiplications.c) In time proportional to n (for the additions), we may reduce a problem of size n to 3 problems of size n/2. So in the Master Theorem (Theorem 4.1 of Cormen et al), a=3, b=2, and f(n) is Θ(n), which is O(nlg 3). So case 1 of the theorem applies, and the asymptotic time complexity for T(n), the number of bit multiplications, is Θ(nlg 3).
b) The minimum cut divides V into S = {s,x} and T = {y,t}.
c) Several equivalent answers are possible. One is
sx <= 10, sy <= 4, xy <=3, xt <= 4, yt <=8
sx - xy +xt = 0, sy + xy - yt = 0,
sx >= 0, sy >= 0, xy >= 0, xt >=0, yt >=0,
where the function to be maximized is sx + sy
d) A Ford-Fulkerson algorithm could augment the null flow by the paths (s,x,t), (s,y,t), and (s,x,y,t) with respective flows 4, 4, and 3. It needn't augment in this order. Here the total flow of 4 + 4 + 3 is 11, as in (a), and the minimum cut crosses edges (s,y), (x,y), and (x,t), with respective flows 4, 3, and 4, which again total 11.
In the linear programming case, there would be slack variables and constraints
Note that this solution is the same as that given by Ford-Fulkerson -- in fact, the last three substitutions correspond to augmentations. In particular, it is consistent with (a) and (b). Also, this solution may be obtained in many different ways, since variables may be rewritten in many different orders.