How to find computational complexity?

Click For Summary

Discussion Overview

The discussion revolves around methods for determining the computational complexity of programs. It includes theoretical approaches, practical considerations, and references to resources for further study.

Discussion Character

  • Exploratory, Technical explanation, Homework-related

Main Points Raised

  • One participant inquires about methods to find the computational complexity of a program, suggesting the possibility of using a background program.
  • Another participant proposes that a first step is to count nested loops and their execution frequency, providing an example of three nested loops resulting in a complexity of \mathcal{O}(n^3) under certain conditions.
  • It is mentioned that for operations involving bignums, the complexity can depend on the size of the numbers, with a specific example given for schoolbook multiplication leading to a complexity of \mathcal{O}(x(\log x)^2).
  • A participant requests resources for further information on computational complexity.
  • Another participant suggests that programming language standards often specify the asymptotic running time for standard library functions and recommends the book "Introduction to Algorithms" by CLRS for analyzing one's own code.

Areas of Agreement / Disagreement

Participants present various methods and resources for analyzing computational complexity, but there is no consensus on a single approach or method, indicating multiple views remain on how to best determine complexity.

Contextual Notes

Some assumptions about the nature of operations and the context of the program being analyzed are not explicitly stated, which may affect the applicability of the proposed methods.

Who May Find This Useful

Individuals interested in programming, algorithm analysis, and computational complexity, particularly students and professionals in computer science and software development.

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 [itex]\mathcal{O}(n^3)[/itex].

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 [itex]\mathcal{O}(x(\log x)^2)[/itex].
 
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.
 

Similar threads

  • · Replies 102 ·
4
Replies
102
Views
4K
Replies
6
Views
3K
Replies
10
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
5K
Replies
29
Views
6K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K