Jump to content
  • Advertisement
Sign in to follow this  
xandra

need heli in O-notation please

This topic is 4273 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!