Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Advanced Data Structures

Name: Anonymous 2015-05-04 23:22

How often is the answer to a tricky programming problem to use a fancy data structure?

Name: Anonymous 2015-05-17 16:29

>>35
No, it's still Θ(n). You have to allocate a new, larger array, then copy all the n items from the old array to the new, then free the memory taken up the the old array.

Only when the allocated array is full. Note the size and capacity vars. size is the number of elements in the array. capacity is the memory allocated to the array. size is always less than capacity. e.g. Initialize with size = 0 and capacity = 1024. That gives you 1024 O(1) append operations before capacity needs to be increased and objs needs to be reallocated. It's Θ(1), trust me.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List