Quote:

Originally Posted bySaswatPadhiCrazyGal is right, it's O(n^2), but it would be better to say it's O(n*m).

The "histogram" algorithm is O(n) even though there are 2 parses and you might think it's O(2n), but again that's misunderstanding what the O syntax is designed for. As n increases, the time for the algorithm only increases linearly, e.g. if n increases by 5% then the overall time increases by 5%.

Quote:

You see the use of strchr(), which searches for a character inside string b. It performs 'm' operations : matches the character with each char of string b.

As strchr() is executed in each iteration of the "while" loop, total number of operations is n*m.

See http://en.wikipedia.org/wiki/Big_O_notation for more information than you ever wanted to know about Big O notation.