Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithm Efficiency

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.

like image 600
HashHazard Avatar asked Jan 23 '13 16:01

HashHazard


People also ask

What are the 2 kinds of algorithm efficiency?

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.

How do we measure an algorithm efficiency?

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.

What is the most efficient algorithm?

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.

Why is algorithmic efficiency important?

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.


1 Answers

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.

like image 71
Mihai Maruseac Avatar answered Oct 13 '22 09:10

Mihai Maruseac