Time Complexity in Reversing a C++ String -


i have problem on homework reverse words in c++ string, in place, o(1) additional memory. i'm confused means o(1) additional memory. understand o(1) means, no matter how big input is, time compute constant i'm guessing should add 1 piece of memory keep track of words in reverse. suggestions?

o(1) additional memory means "using @ constant additional memory." example, couldn't store copy of string, since take o(n) space, store constant number of ints, chars, etc.

more generally- statements "o(1)" or "o(n)" don't refer runtimes. big-o notation way of describing functions. algorithm can't o(n), runtime can o(n). algorithm's space usage can o(1), o(n), o(2n), etc.

hope helps!


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -