Re:Show HN: Array with Constant Time Access and Fast Inserti...
by kccqzy on Wednesday September 04, 2019 @01:18AM
(#20874210)
In C++ the std::vector type handles this by doubling the capacity when full. I think this approach also works for this data structure. When the capacity has been reached simply double the capacity and rebuild from scratch. Perhaps quadruple because then each double-ended queue would double in size, avoiding that pesky sqrt(2). The amortized time should be the same.
[ Parent
| on HN ]
Re:Show HN: Array with Constant Time Access and Fast Inserti...
by saagarjha on Wednesday September 04, 2019 @01:34AM
(#20874297)
> In C++ the std::vector type handles this by doubling the capacity when full.
Of course, the growth factor is implementation-dependent and I believe some compilers use smaller growth factors to improve performance.