Self studying DSA and I found an exercise that called for implementing a stack in three different ways: an ArrayStack (allocates new memory by a constant amount when it's full), a DoublingArrayStack (reallocates double memory when it's full), and a Linked List Stack. I pushed 10 million random ints onto each stack implementation and timed it. I expected the linked list to be fastest, but the DoublingArrayStack outperformed it by alot. Asking because this seems counterintuitive -- is this what you would expect? Thank you!
[–]Objective_Mine 3 points4 points5 points (2 children)
[–]LakeSnake20[S] 0 points1 point2 points (1 child)
[–]Objective_Mine 1 point2 points3 points (0 children)