Question: When counting the number of arithmetic operations in evaluating an expression, we often make the simplifying assumption that each operation has the same cost. For
When counting the number of arithmetic operations in evaluating an expression, we often make the simplifying assumption that each operation has the same cost. For example, consider the following statement from the Merge-Sort algorithm for dividing the problem into two equal problems. q=1(p+r)/2] We would say that the evaluation requies a total of 3 arithmetic operations (+,/ and floor"). That is, the time cost is 3. If that statement was embedded in a loop that executed 5 times, then we would say that the statement has a time cost of 5*3 = 15 arithmetic operations. Now consider this equation that was used in calculating the execution time for insertion sort 2=2] = n(n+1) 1 What is the difference in the time cost T(n) in terms of the number of arithmetic operations required to compute this formula depending on whether the algorithm is expressed based on the summation approach on the left-hand side of the equation or based on the closed formula approach on the right hand side of the equation as a function of the problem size n? You should express your analysis using the theta (O) notation. (10 points) When counting the number of arithmetic operations in evaluating an expression, we often make the simplifying assumption that each operation has the same cost. For example, consider the following statement from the Merge-Sort algorithm for dividing the problem into two equal problems. q=1(p+r)/2] We would say that the evaluation requies a total of 3 arithmetic operations (+,/ and floor"). That is, the time cost is 3. If that statement was embedded in a loop that executed 5 times, then we would say that the statement has a time cost of 5*3 = 15 arithmetic operations. Now consider this equation that was used in calculating the execution time for insertion sort 2=2] = n(n+1) 1 What is the difference in the time cost T(n) in terms of the number of arithmetic operations required to compute this formula depending on whether the algorithm is expressed based on the summation approach on the left-hand side of the equation or based on the closed formula approach on the right hand side of the equation as a function of the problem size n? You should express your analysis using the theta (O) notation. (10 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
