Professional Documents
Culture Documents
Pavel Krotkov
Saint Petersburg 2016
Operations on vector
2/9
Operations on vector
2/9
Operations on vector
2/9
Operations on vector
2/9
Operations on vector
2/9
Operations on vector
2/9
Organizing vector in memory
3/9
Organizing vector in memory
3/9
Organizing vector in memory
3/9
Extra space
4/9
Extra space
4/9
Extra space
3 6 2
4/9
Extra space
3 6 2
I vector of 5 elements
3 6 2 5 8
4/9
Inserting elements
3 6 2 3 6 2 5
5/9
Inserting elements
3 6 2 3 6 2 5
Special case: vector size is equal to array size.
5/9
Inserting elements
3 6 2 3 6 2 5
Special case: vector size is equal to array size.
Let’s allocate array of doubled size, copy all elements and insert new element.
3 6 2 5 3 6 2 5 8
5/9
Complexity analysis
6/9
Complexity analysis
6/9
Complexity analysis
6/9
Complexity analysis
6/9
Complexity analysis
6/9
Complexity analysis
6/9
Complexity analysis
7/9
Complexity analysis
7/9
Complexity analysis
7/9
Complexity analysis
7/9
Complexity analysis
7/9
Removing elements
8/9
Removing elements
8/9
Removing elements
8/9
Thank you
for your attention!
9/9