Presentation is loading. Please wait.

Presentation is loading. Please wait.

Level 1 STL – Linear DS fb.com/acmicpcfcicu. Static Arrays Creating 1D, 2D, ND Static Arrays. Accessing Time. Traversing a static array with N dimensions.

Similar presentations


Presentation on theme: "Level 1 STL – Linear DS fb.com/acmicpcfcicu. Static Arrays Creating 1D, 2D, ND Static Arrays. Accessing Time. Traversing a static array with N dimensions."— Presentation transcript:

1 Level 1 STL – Linear DS fb.com/acmicpcfcicu

2 Static Arrays Creating 1D, 2D, ND Static Arrays. Accessing Time. Traversing a static array with N dimensions. 1D Array Manipulation. 2D Array Manipulation.

3 Dynamically-Resizable Arrays (Vectors) Creating Vector vector v; vector v(10); //create vector with initial size 10, and initialize it by zeros Important Functions: – push_back(), pop_back(), size(), insert() How resizing is done internally + resizing complexity.

4 Pairs pair contestant; contestant.first = 6; contestant.second = 234; cout << contestant.first << “ “ << contestant.second << endl; contestant = make_pair(6, 234); contestant = {6, 234}; // C++ 11

5 Iterators vector v; v.push_back(10); v.push_back(20); vector ::iterator it = v.begin(); //pointing to the first element cout << *it << endl; // 10 it = find(v.begin(), v.end(), 20); if(it == v.end()){ cout << “10 Not found”; }else{ v.erase(it); cout << “New vector size is: “ << v.size() << endl; }

6 Algorithm sort(v.begin(), v.end()); sort(v.begin(), v.end(), sort_contestants); reverse(v.begin(), v.end()); find(v.begin(), v.end(), 10);

7 Stacks

8 Last In First Out Creating Stack stack s; Important Functions: – push(), top(), pop(), size()

9 Queues

10 First In First Out Creating Queue queue q; Important functions and their complexities. – push(), front(), pop(), size()

11 Dequeues Creating Dequeue Important functions and their complexities. – front(), back(), push_front(), push_back(), pop_front(), pop_back()

12 Bit Manipulation Bitwise operations: |, &, ^, ~, >>, << setBit clearBit getBit toggleBit


Download ppt "Level 1 STL – Linear DS fb.com/acmicpcfcicu. Static Arrays Creating 1D, 2D, ND Static Arrays. Accessing Time. Traversing a static array with N dimensions."

Similar presentations


Ads by Google