DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   C (http://www.daniweb.com/forums/forum118.html)
-   -   A couple of ?s on algorithms. Help Plz (http://www.daniweb.com/forums/thread36888.html)

nabil1983 Dec 17th, 2005 11:35 am
A couple of ?s on algorithms. Help Plz
 
Trying to understand how to do this Q. Can some explain using O-notation, how would i analyse the efficiency of the two algorithms below. ?

Assuming that the critical operation is compute and size is the size of the array.

1) compute(a[1]) + compute(a[2]) + compute(a[3]) + compute(a[size])

2) for k = 1 to size for j = 1 to size compute(a[j])

I just need someone to xplain this briefly so that i can understand how i would analyze algorithms of such in the future.

Also what is meant by the terms 'Programming Time' and 'Execution Time' in relation to algorithms.?



Apreciate ne help

Ancient Dragon Dec 18th, 2005 3:44 pm
Re: A couple of ?s on algorithms. Help Plz
 
Quote:

Originally Posted by nabil1983
Also what is meant by the terms 'Programming Time' and 'Execution Time' in relation to algorithms.?


how long time it takes for the algorithm to execute. For example, if testing a sort algorithm, how long does it take the alogithm to sort the data. That is normally measured by getting current system time before starting the algorithm, again after and subtacting the two.
clock_t t1 = clock(); // get start time
// do algorithm
clock_t t2 = clock();// get end time

clock_t delta_time = t2 - t1; // difference

nabil1983 Dec 18th, 2005 10:48 pm
Re: A couple of ?s on algorithms. Help Plz
 
thanx bro.


All times are GMT -4. The time now is 11:40 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC