Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+/ Review of organizational literature/information

Answered: 1 week ago

Question

1. Define the nature of interviews

Answered: 1 week ago

Question

2. Outline the different types of interviews

Answered: 1 week ago