Big O for the delete [] operator

If you have a dynamic array and call delete [] to return the array to the heap, is that a constant function or a linear function? Any clarification would be appreciated.
IIRC, the specifics of it may actually be up to the implementation. So I think it would be compiler dependent, though even if it was I wonder if the makers would bother to note it anywhere.
delete[] for POD types is typically O(1). When destructors must be called, delete[] is O(n).
Thanks for the replies. So if I have a destructor for say a sequence class that has a dynamic array private member variable data, and I implement the destructor as
1
2
3
4
sequence::~sequence()
{
    delete [] data;
}


Then in that instance, the Big-O for the destructor (and therefore the delete operator) is O(n)?
Last edited on
It depends on whether data is an array of POD or non-POD types.
Topic archived. No new replies allowed.