Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this document? Why not share!

# Q

## on May 04, 2009

• 2,785 views

### Views

Total Views
2,785
Views on SlideShare
2,785
Embed Views
0

Likes
0
77
0

No embeds

### Report content

• Comment goes here.
Are you sure you want to

## QDocument Transcript

• Questions and exercises for Review Note. Questions/Exercises in green numbers apply to the midterm 1. What steps should one take when solving a problem using a computer? A: first to construct an exact model in terms of which we can express allowed solutions. Once we have a suitable mathematical model, we can specify a solution in terms of that model 2. Explain some issues when dealing with the representation of real world objects in a computer program. A: how real world objects are modeled as mathematical entities, the set of operations that we define over these mathematical entities, how these entities are stored in a computer's memory (e.g. how they are aggregated as fields in records and how these records are arranged in memory, perhaps as arrays or as linked structures), and the algorithms that are used to perform these operations. 3. Explain the notions: model of computation; computational problem; problem instance; algorithm; and program A: Model of Computation: An abstract sequential computer, called a Random Access Machine or RAM. Uniform cost model. Computational Problem: A specification in general terms of inputs and outputs and the desired input/output relationship. Problem Instance: A particular collection of inputs for a given problem. Algorithm: A method of solving a problem which can be implemented on a computer. Usually there are many algorithms for a given problem. Program: Particular implementation of some algorithm. 4. Show the algorithm design algorithm A: 5. What might be the resources considered in algorithm analysis? A: • running time • memory usage (space) • number of accesses to secondary storage • number of basic arithmetic operations
• • network traffic 6. Explain the big-oh class of growth. A: O(g) is the set of functions that grow no faster than g. g(n) describes the worst case behavior of an algorithm that is O(g) Examples: n lg n + n = O(n2);;;;; lgk n = O(n) for all k ∈ N 7. Explain the big-omega class of growth. A: Ω (g(n)): class of functions f(n) that grow at least as fast as g(n) g(n) describes the best case behavior of an algorithm that is Ω(g) Example: a n2 + b n + c = Ω(n) provided a > 0 8. Explain the big-theta class of growth. A: Θ (g(n)): class of functions f(n) that grow at same rate as g(n) Example:n2 / 2 - 3 n = Θ(n2) We have to determine c1 > 0,c2 > 0, n0 ∈ N such that:c2 n2 ≤ n2 / 2 - 3 n ≤ c1 n2 for any n > n0. Dividing by n2 yields:c2 ≤ 1 / 2 – 3 / n ≤ c1 This is satisfied for c2 = 1 / 14, c1 = 1 / 2, n0 = 7. 9. What are the steps in mathematical analysis of nonrecursive algorithms? A: • Decide on parameter n indicating input size • Identify algorithm’s basic operation • Determine worst, average, and best case for input of size n • Set up summation for C(n) reflecting algorithm’s loop structure • Simplify summation using standard formulas 10. What are the steps in mathematical analysis of recursive algorithms? A: Decide on parameter n indicating input size • Identify algorithm’s basic operation • Determine worst, average, and best case for input of size n • Set up a recurrence relation and initial condition(s) for C(n) − the number of times the basic operation will be executed for an input of size n (alternatively count recursive calls). • Solve the recurrence to obtain a closed form or estimate the order of magnitude of the solution 11. From lowest to highest, what is the correct order of the complexities O(n2), O(3n), O(2n), O(n2 lg n), O(1), O(n lg n), O(n3), O(n!), O(lg n), O(n)? A: O(1),O(logn),O(n),O(2n),O(3n),O(nlogn),O(n*n lgn ),O(n*n),O(n*n*n),O(n!) 12. What are the complexities of T1(n) = 3n lg n + lg n; T2(n) = 2n + n3 + 25; and T3(n, k) = k + n, where k less-than or equal to n? From lowest to highest, what is the correct order of the resulting complexities? A: O(t1)=nlogn;;;;;O(t2)=2la put n;;;;;;O(t3)=n t3,t1,t2