Assume that in the worst case an algorithm takes 1 second to

Assume that, in the worst case, an algorithm takes 1 second to process 100 elements. How long will it take to process 2,000 elements if the growth rate of the algorithm is

(a) O(N) so I understand that 2000/100 = 20 seconds

(b) O(N2)

would (b) be 40,000 seconds or 200 seconds? im not sure if im reading the problem correctly and am confused if I should do 20^2 or

2000^2 = 4000000

4000000/100 = 40000 seconds

Solution

Hi

In the Below Question
The N stands for the number of elements. So If it is O(N^2) then the complexity is more
and it has to compare square of times .

To process
      
       100 Elemnets --> 1 Sec( Here n = Elements )
       2000 Elements --> 20 sec

   It is pretty clear that Elements/100 = Sec
If this is Considered as O(n) .

Then O(N2) would be clearly 2000^2 = 4000000/100 = 40000 Sec


HOpe This should help you .

Let me know in case of any queries .

Assume that, in the worst case, an algorithm takes 1 second to process 100 elements. How long will it take to process 2,000 elements if the growth rate of the a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site