Depth determination In the depth-determination problem, we maintain a forest F D fTi g of rooted trees under three operations: MAKE-TREE./ creates a tree whose only node is . FIND-DEPTH./ returns the depth of node within its tree. GRAFT.r; / makes node r, which is assumed to be the root of a tree, become the child of node , which is assumed to be in a different tree than r but may or may not itself be a root. a. Suppose that we use a tree representation similar to a disjoint-set forest: :p is the parent of node , except that :p D if is a root. Suppose further that we implement GRAFT.r; / by setting r:p D and FIND-DEPTH./ by following the find path up to the root, returning a count of all nodes other than encountered. Show that the worst-case running time of a sequence of m MAKETREE, FIND-DEPTH, and GRAFT operations is .m2/. By using the union-by-rank and path-compression heuristics, we can reduce the worst-case running time. We use the disjoint-set forest S D fSi g, where each set Si (which is itself a tree) corresponds to a tree Ti in the forest F . The tree structure within a set Si , however, does not necessarily correspond to that of Ti . In fact, the implementation of Si does not record the exact parent-child relationships but nevertheless allows us to determine any nodes depth in Ti . The key idea is to maintain in each node a pseudodistance :d, which is defined so that the sum of the pseudodistances along the simple path from to the of its set Si equals the depth of in Ti . That is, if the simple path from to its root in Si is 0; 1;:::;k, where 0 D and k is Si s root, then the depth of in Ti is Pk jD0 j :d. b. Give an implementation of MAKE-TREE. c. Show how to modify FIND-SET to implement FIND-DEPTH. Your implementation should perform path compression, and its running time should be linear in the length of the find path. Make sure that your implementation updates pseudodistances correctly. d. Show how to implement GRAFT.r; /, which combines the sets containing r and , by modifying the UNION and LINK procedures. Make sure that your implementation updates pseudodistances correctly. Note that the root of a set Si is not necessarily the root of the corresponding tree Ti . e. Give a tight bound on the worst-case running time of a sequence of m MAKETREE, FIND-DEPTH, and GRAFT operations, n of which are MAKE-TREE operations.

L3 - 11 Now You Try It (NYTI): x − cosx 1. Is f(x)= even, odd, or neither Verify your answer. x 3 2 3π 3π 2. Suppose that sinα = − 5,t β = − , 3