Question: An algorithm takes f(N) seconds to run the algorithm. Determine the maximum value of N, that the algorithm can complete in (a) one minute (b)

  1. An algorithm takes f(N) seconds to run the algorithm. Determine the maximum value of N, that the algorithm can complete in (a) one minute (b) in one hour and (c) in one day.

Given f(N) = N(N-1)/2


This can be done by writing a computer program, with a function for f(N) and then in the main, initialize N to 1, and then write a loop to check f(N) < time, where time = 60 for (a), time = 3600 for (b) and time = 86400, and inside the loop increment N by 1


Once outside the loop, display the value of N-1


The pseudocode for the main function is given as below:


Get Value for time

N 1

while f(N) < time

N N + 1

Print N-1 with suitable title


So, the program should have defined the function f(N) and also write the main.




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!