Re:Show HN: Array with Constant Time Access and Fast Inserti...
by juliusmusseau on Tuesday September 03, 2019 @08:49PM
(#20872929)
I'd like to see the performance of growing the list (a common scenario):
(Forgive me, Java is my mother tongue).
[ Parent
| on HN ]
Re:Show HN: Array with Constant Time Access and Fast Inserti...
by kadoban on Tuesday September 03, 2019 @09:02PM
(#20873011)
I believe this case is very badly handled in this data structure implementation. It seems to be saying that you want to occasionally manually recreate the DS as it grows bigger, as the deqs won't automatically resize. So you'll just have linear behavior in that case, with extra constants because the deqs are useless logic.
I suspect an amortized data structure could automatically and internally do this rebalancing operation, but I'd have to work out the scheme and the analysis. At a guess, something like normal dynamic arrays do, where you multiply the max size by a constant when it fills up, would give you decent amortized bounds.
Re:Show HN: Array with Constant Time Access and Fast Inserti...
by igushev on Tuesday September 03, 2019 @09:10PM
(#20873063)
Correct. I need to add automatic restructuring. Currently structure sensitive and benefits a lot from using reserve() method
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.
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.
Re:Show HN: Array with Constant Time Access and Fast Inserti...
by rurban on Wednesday September 04, 2019 @03:24AM
(#20874784)
Th optimal growth factor is the golden ratio 1+sqrt(5) [1.618], but 2 is much faster to calculate.
Re:Show HN: Array with Constant Time Access and Fast Inserti...
by saagarjha on Thursday September 05, 2019 @01:06AM
(#20883990)
Is calculating the new size really the bottleneck here?
Re:Show HN: Array with Constant Time Access and Fast Inserti...
by michaelrpeskin on Tuesday September 03, 2019 @09:23PM
(#20873121)
Here’s an old article about the performance characteristics of Deques.
https://www.codeproject.com/Articles/5425/An-In-Depth-Study-...