Sign in to follow this  
xandra

need heli in O-notation please

Recommended Posts

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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this