Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ComputeSumLowerTri angular ( L , n ) inputs: L is an n n matrix. n is the dimension of the matrix output: a real number

ComputeSumLowerTri angular (L,n)
inputs: L is an nn matrix. n is the dimension of the matrix
output: a real number equal to
sum =0
for im=n to 1
psum =0
for j =1 to im
Dsum = psum ,
sum = sum +psum
return sum
All the questions in this exercise are related to the ComputeSumLowerTriangular (Lin n)
algorithm. The objective of this exercise is to explore whether the asymptotic time complexity
will change if we count different "actions".
A)(40 points) Comparison Action (Lines 2 and 4).
In this case, we count the total number of comparisons performed by the "for loops statements" (Lines 2 and 4
only). Answer the following questions to determine the total number of comparisons performed by the algorithm.
a.(2 points) How many comparisons in total are performed by the "for loop" statement in Line 2
during the execution of the algorithm? (See on the appendix how Student 3 gets full credit)
answer here .....
b.(20 points) Let us call ti the number of comparisons performed by the inner "for loop" in Line
4 for a given value of j. Fill in this table (Justify how you find ti using exactly the same steps
and sentence pattern shown below for j=1):
c.(8 points) Based on b, express the total number of comparisons performed by the inner "for
loop" in Line 4 only during the execution of the algorithm. (See how Student 3 gets full credit)
answer here ...
d.(8 points) Express the function fc(n) that represents the overall total number of comparisons
performed by the "for loops" statements in Lines 2 and 4 during the execution of the algorithm.
(See how Student 3 gets full credit)
answer here ...
e.(2 point) The function fc(n) grows like
credit)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions