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.
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)?