Question: . Suppose we have the following algorithm: 1 : Algorithm Cartesian ( A , B , n ) 2 : Input: A and B ,
Suppose we have the following algorithm:
: Algorithm CartesianA B n
: Input: A and B two nelement lists
: Output: The Cartesian product of the two lists: A BA B
: Let C be an empty list
: for i from to n do
: for j from to n do
: Add Ai Bj to the end of C
: return C
: End.
a What is the time complexity using the RAM model ie directly counting operations
Make sure you explain your answer in terms of the operations you consider primitive.
b Is this algorithms running time On
Why or why not?
c Is this algorithms running time Theta n
Why or why not?
d Is this algorithms running time n Why or why not?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
