Tuesday 15 January 2013

algorithm - copying data structures and space complexity -



algorithm - copying data structures and space complexity -

i asked write functions take type of parameter such string , manipulate in way lot easier if other info structure. can convert string character array , set string null while considering function take o(1) space or copying elements create o(n) if delete other copy? utilize strings illustration because immutable. in case, seek delete info 1 construction add together other.

i using string , char[] examples here. in general, want know if copying info reduces space complexity of algorithm if i'm deleting other copy.

copying penalizes space complexity because original , re-create both in memory @ same time (even if briefly case), need have memory available. in-memory algorithm able execute if don't have more memory available.

algorithm space-complexity

No comments:

Post a Comment