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)

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

Recommended Answers

All 2 Replies

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

thanx bro.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.