So this is a question in my homework....
Given that the efficiency of an algorithm is n3, if a step in the algorithm takes 1 ns (10-9) seconds), how long does it take the algorithm to process an input of size 1,000?
Here is MY question: How do I figure this out? PLEASE DO NOT POST THE ANSWER. Help me learn how to figure this out for myself.
Time efficiency - a measure of amount of time for an algorithm to execute. Space efficiency - a measure of the amount of memory needed for an algorithm to execute.
One way to measure the efficiency of an algorithm is to count how many operations it needs in order to find the answer across different input sizes.
Quicksort. Quicksort is one of the most efficient sorting algorithms, and this makes of it one of the most used as well. The first thing to do is to select a pivot number, this number will separate the data, on its left are the numbers smaller than it and the greater numbers on the right.
The efficiency of the algorithms used in an application can impact its overall performance; hence, the importance of measuring the performance and complexity of algorithms through means that are accessible not only to mathematicians but also to any software engineer who aims to excel in algorithm design.
You define n
to be 1000
. Thus, you need n3 steps, each one of them taking 1 ns
. Multiply the two and you have the answer.
General idea: if an algorithm needs f(n)
number of steps and one step takes t
then you need t * f(n)
for the algorithm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With