An algorithm having worst-case running time of O(N^2) took 30secs to run for input size N=20. How long will the same algorithm take for input size N=400 ?
An algorithm having worst-case running time of O(N^2) took 30secs to run for input
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
O(n^2) implies proportionality to the square of n (see this guide). So
Hence time for 400 items
So that 12000 seconds.
Now, that’s not necessarily true unless you know that the original 20 item test was a worst case scenario, if it isn’t then we have a bad estimate of K. Even if if we have a good estimate of K so we we know the worst case scenarion for 400 items, we don’t know that these 400 items will take that long.