Array insert cost
A live feed calls posts.insert(newPost, at: 0) every time a new post arrives. What goes wrong once 50,000 posts have piled up?
A live feed calls posts.insert(newPost, at: 0) every time a new post arrives. What goes wrong once 50,000 posts have piled up?
Inserting at the front is an O(n) shift, so at 50,000 posts every insert moves hundreds of kilobytes. If something else also references that array, a full COW copy lands on top.
CS fundamentals and algorithmsMultiple choiceIntro
You're picking a data structure for the message list on a chat screen. Which is the most…
#array #complexity
CS fundamentals and algorithmsMultiple choiceIntro
Which of these Swift collection operations have O(1) average time complexity? Select all…
#array #complexity
Memory and ARCShort answerAdvanced
… After s2.a = 9, are the addresses where s1.a and s2.a are stored the same or different…
#array #cow
Performance and debuggingMultiple choiceIntro
With the same 100,000 elements stored in each, which operations are clearly faster on a…
#array #complexity