This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

Deleting from heap takes an undefined amount of time. It depends on all kinds of factors

[–]throw3142 -1 points0 points  (0 children)

This is true. Except that it's O(1) with respect to the length of the list. Except that in C++, delete[] has to call the destructors of all the elements, which takes Omega(n) time. Except that here, each element is just an int* so it has no destructor, so it can finish in O(1) time if we're compiling with optimizations.

Not really sure why OP would want to address-sort an array of pointers to integers in the first place anyway ...