Are there any common techniques used for calculating Algorithm Complexity?

Big O is standard. Although developed as a part of pure mathematics, this notation is now frequently also used in the analysis of algorithms to describe an algorithm's usage of computational resources: the worst case or average case running time or memory usage of an algorithm is often expressed as a function of the length of its input using big O notation.

O(1) means you perform a series of instructions a constant number of times (which simply put means you don't use any loops). O(n) means you have one loop which performs O(1) operations inside (for example I search through a list for a specific value). O(log n) is searching through a list utilizing an intelligent indexing system such as a binary tree or hash map.

With every pass, you're essentially eliminating half the possibilities (unlike O(n) which eliminates them one at a time). O(n^2) means you have an inner and outer loop for performing cross checks (if I wanted to cycle through all items in an grid, I'd start by cycling through all rows and then through each cell of each row for instance). You could generalize this as O(n^m) where m represents the maximum loop depth in your program which cycles for n times.

O(2^n) means that you're cycling through every possible combination of a set. If I have items {A, B}, then cycling through every possible combination would result in {{}, {A}, {B}, {AB}}. O(n!) is exhausting every possible scenario.

Trying to crack a password through brute force is an example of O(n! ). You can't get worse than this, and algorithms which are O(n!

) exist because there are no other alternatives (P and NP complete for example). This is a fairly quick summary, but that's the gist of it. Technically loops which cycle a constant number of times are O(1) unless it contains an inner loop.

What's important is that you're not looping an unknown number of times.

Thanks for explaining in simple terms – Wajih Nov 2 '10 at 13:31.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions