randomx generates a random number between 1 and x with unifo

random(x) generates a random number between 1 and x with uniform distribution.

int func6(int A[], int n) {if (n lessthanorequalto 100) return(0); x=A[1];) for (i = 0; i

Solution

Answer:

It has two loops :

One running from 0 to n/2

Other running from 0 to n/2

Hence total complexity is O(n/2) * O(n/2) = O(N^2/4) = O(n^2)

a) Worst case running time = O(n^2)

b) Expected = O(n).

random(x) generates a random number between 1 and x with uniform distribution. int func6(int A[], int n) {if (n lessthanorequalto 100) return(0); x=A[1];) for (

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site