Hacker Newsnew | past | comments | ask | show | jobs | submit | cpppppp55's commentslogin

Sometimes pushing into a vector is O(n), but typically not. So it’s the penalty of allocating new data memory when the underlying array needs a resize that’s amortized for multiple push calls.

Similarly with a typical hashmap, the keyspace should occasionally collide, meaning non-edgecases would amortize to O(1) for multiple inserts.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: