o-notation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xandra
    New Member
    • Nov 2006
    • 9

    o-notation

    i have another question regarding the o-notation.
    how does using strings insted of simple types like integers alter the
    o-notation of operations?
    thanks
  • dtimes6
    New Member
    • Oct 2006
    • 73

    #2
    This infact is a very hard question!
    That depends on what is the use of the string. And how u use it!

    Comment

    • Ganon11
      Recognized Expert Specialist
      • Oct 2006
      • 3651

      #3
      In general, using strings does not seriously affect Big-O notation. Of course, it depends on what you're doing with it.

      Recall that a string can be considered an array of characters. Thus, if you were accessing each character of a string, this would be the same as accessing each member of an integer array (a.k.a. O(n)). Also, using a string method (such as stringVariable. find(char OR string)) will have a certain run-time - .find() probably has O(n) (since it will perform a linear search through the string), and .substr() probably has O(1) (since it will take a constant time to get the substring). Of course, these are just my guesses, so I'm not completely sure.

      Generally, treat strings as character arrays for purposes of determining Big-O notation,

      Comment

      Working...