1. Show that if *f*(*n*) is *O*(*h*(*n*)) and *g*(*n*) is *O*(i(*n*)), then *f*(*n*) + *g*(*n*) is *O*(*h*(*n*) + i(n)).

2. Show that 3(*n *+ 1)^{7} + 2*n *log *n *is *O*(*n*^{7}). **Hint:*** *Try applying the rules of Theorem 1.7. You will have to use the insert equations to answer this question.

3. Give an *O*(*n*)-time algorithm for computing the depth of each node of a tree *T*, where *n *is the number of nodes of *T*. Assume the existence of methods setDepth (*v*,*d*) and getDepth(*v*) that run in *O*(1) time.

4. What does the following algorithm do? Analyze its worst-case running time and express it using "Big-Oh" notation.

**Algorithm** Foo *(a,n):*

*Input*: two integers, *a* and *n*

*Outpu*t: ?

*k* ß 0

*b* ß 1

**while** *k* < *n* **do**

*k* ß*k + 1*

* b * ß* b* **a*

**return** *b*

5. a. Describe (in pseudo-code) a findAll Elements (*k*) method of an AVL tree *T*. It should run in *O*(logn + *s*) time where *n* is the size of *T* and *s* is the number of elements returned (i.e., the number of nodes in *T* whose key is *k*).

b. Analyze the running time of your algorithm.

### Recently Asked Questions

- A steel railroad track is 1.1 km long at 22.1°C. On a 46.9°C day, how much longer (in meters) is it than at the previous temperature? Give answer to two

- What is the wavelength of the sound emitted by an airplane flying at an elevation of 40,000 feet where the temperature is -58.4°C? The frequency of the noise

- Sunland Company has developed a new product that will be marketed for the first time next year. The product will have variable costs of $25 per unit. Although