Skip to main content

Posts

Showing posts from April, 2018

Containers in c++

SEQUENTIAL CONTAINER Vector (Dynamic Array - Contiguous memory):  O(1): Vectors provide fast (constant time) element insertion and deletion at the end of the vector and Acess. O(n): Slow (linear time) insertion and deletion anywhere else. Insertion and deletion are slow because the operation must move all the elements “down” or “up” by one to make room for the new element or to fill the space left by the deleted element. Like arrays, vectors provide fast (constant time) access to any of their elements. List (Doubly Linked List - Not  Contiguous memory ): O(n): Lists provide slow (linear time) element lookup and access, O(1):  (constant time) insertion and deletion of elements once the relevant position has been found Deque (Doubly Ended Queue - Not Contiguous memory): O(1): (constant time) element access. Like a list, it provides fast (amortized constant time) insertion and deletion at both ends of the sequence. O(1):  (lin...