I was wondering if there was any append-only data structure that supports worst-case O(1) appending, and random access.
I saw this answer, but the problem in my eyes is that whenever you fill up the array, you have to allocate a new array that's twice the size, so that would be O(n) worst case for appending.
However, I saw one of the answers in that question was to use std::deque
. It also said that std::deque
supports O(1) random access & insertion. Is that true?
I'm using C++.