More Programming Pearls: Confessions of a Coder

Category: Computer Science
Author: Jon Louis Bentley
4.0

Comments

by anonymous   2017-09-05
Repeated reallocation for a change of one in the array size is not particularly good. You'd likely do better with allocating as much space as you'll need all at once, or keep track of what's allocated and what's in use and only allocate more when necessary. Jon Bentley's [Programming Pearls, 2nd Edn](https://www.amazon.com/dp/0201657880/) from 1999 and [More Programming Pearls](https://www.amazon.com/dp/0201118890/) from 1988 include code for handling array-based heaps as you are using. You can find an outline of that code in [this answer](https://stackoverflow.com/a/21742125) of mine.