How to find computational complexity?

AI Thread Summary
To determine the computational complexity of a program, start by analyzing the structure of the code, particularly focusing on nested loops. For example, three nested loops each iterating from 1 to x with constant-time operations result in a complexity of O(n^3). When dealing with bignums, the cost of operations varies based on the size of the numbers, often leading to complexities like O(x(log x)^2) for operations such as schoolbook multiplication. For further understanding, refer to programming language standards that outline the asymptotic running times of standard library functions. A highly recommended resource for deeper insights into algorithm analysis is "Introduction to Algorithms" by Cormen, Leiserson, Rivest, and Stein (CLRS).
Coolphreak
Messages
44
Reaction score
0
If i have a program, how can i find the computational complexity? is there some other program i can run in the background?
 
Technology news on Phys.org
A first step would be counting the nested loops and looking at the number of times they execute. If you have three nested loops, each running from 1 to x, and inside the three you have operations taking constant time (i.e. not dependent on the size of any variable) then the complexity is \mathcal{O}(n^3).

If you're using bignums or the like you'll have to look into how much each operation costs based on the size of the numbers -- that's usually log(x)^k log(log(x))^n for some k and n. If you have a loop from 1 to x doing schoolbook multiplication on a bignum of size x, that's complexity \mathcal{O}(x(\log x)^2).
 
Last edited:
thanks for your help. can u point me to some resource where i can look some of this stuff up?
 
If you're using standard library functions, most programming language standards will specify the mandatory asymptotic running time in the standard. If you're wanting to analyse your own code, then a good book (the standard in universities, pretty much), is Introduction to Algorithms by CLRS.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top