Question: data structure by using java Find space and time complexity for the following algorithm: i=1; k=1; while(k 0) { i += y; k= y/2; }

data structure by using java

Find space and time complexity for the following algorithm:

i=1;

k=1;

while(k

{

System.out.println(k);

k=k+i;

i++;

}

Describe an algorithm for finding the occurrence of the max element in an array. Analze the time and space complexity of the algorithm.

Find space and time complexity for the given function:

int fun1(int y) {

int i=0;

while(y>0) {

i += y;

k= y/2;

}

return i;

}

int fun2(int n) {

int x = 0;

for (int i=0; i

for (int j=i; j

x += fun1(j);

}

}

return x;

}

Please do the step-by-step analysis and find total space and time complexity separately

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!