(b) 1: function Func(A[],n) 2: X = 0 3: for i = 1 to √n] do m = Random(²) for j = 1 to m² do for k=1 toj do 4: 5: 6: 7: 8: 9: 10: x = x+im- jk end for end for end for

icon
Related questions
Question

Determine the expected case running time of the algorithm. Fully justify your solution.

Determine the best case running time of the algorithm and state what condition must be true for
it to occur. No justification is needed!

Determine the worst case running time of the algorithm and state what condition must be true for
it to occur. No justification is needed!

(b) 1: function Func(A[], n)
2:
X = : 0
3:
for i
4:
5:
6:
7:
8:
9:
10:
end for
11:
return x
12: end function
=
1 to √n] do
m = Random (²)
for j = 1 to m² do
for k=1 toj do
x = x+im- jk
end for
end for
Transcribed Image Text:(b) 1: function Func(A[], n) 2: X = : 0 3: for i 4: 5: 6: 7: 8: 9: 10: end for 11: return x 12: end function = 1 to √n] do m = Random (²) for j = 1 to m² do for k=1 toj do x = x+im- jk end for end for
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer