need heli in O-notation please

Started by
3 comments, last by Zahlman 17 years, 5 months ago
hello: i have aquestion regarding the o-notation. how does using strings insted of simple types like integers alter the o-notation of operations? thank you very much
Advertisement
Do you know what the big-O notation actually is?
Big O notation has nothing to do with types. Like the above poster, I believe you misunderstand what, exactly, Big O notation means. Research might help you.
Actually, I think you may be asking a valid question. An operating on an integer is almost by definition O(1), since the size of an integer is a set number of bits and can usually be accomplished with one instruction.

Many (but not all) operations on a string, such as making the letters all caps, take longer depending on the length of the string, and are usually linear time, O(n), or worse. Some operations might be O(n^2) or worse.

Does that help?
Of course, there are also people for whom operations on "integers" are *not* constant time, because their concept of "an integer" is arbitrary-precision and not limited to 32-bit. This kind of thing is important if you're trying to calculate a zillion digits of pi. :)

For example.

This topic is closed to new replies.

Advertisement