top | item 9528150

(no title)

sharth | 10 years ago

The second problem would be clearer if we knew how much scratch space we had. Is it zero? Is it O(1)? Is it O(n)?

discuss

order

kspiteri|10 years ago

You just need a constant number of pointers. This requires O(log n) scratch space because a pointer can be stored in O(log n) space.

to3m|10 years ago

Not if N=1 ;)

(A constant amount is of course independent of N anyway!)

jgrahamc|10 years ago

Can be solved with no extra storage just three ints or pointers.