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.

Slides:



Advertisements
Similar presentations
More on the STL vector list stack queue priority_queue.
Advertisements

OOP Etgar 2008 – Recitation 101 Object Oriented Programming Etgar 2008 Recitation 10.
Standard Template Library (STL) Overview – Part 1 Yngvi Bjornsson.
CMSC 202 Lesson 24 Iterators and STL Containers. Warmup Write the class definition for the templated Bag class – A bag has: Random insertion Random removal.
Basic C++ Sequential Container Features
1 Stack Data : a collection of homogeneous elements arranged in a sequence. Only the first element may be accessed Main Operations: Push : insert an element.
Rossella Lau Lecture 12, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 12: An Introduction to the STL  Basic.
Lecture 11 Standard Template Library Stacks, Queue, and Deque Lists Iterators Sets Maps.
Dr. Yingwu Zhu STL Vector and Iterators. STL (Standard Template Library) 6:14:43 AM 2 A library of class and function templates Components: 1. Containers:
DATA STRUCTURES ACM EXECUTIVE BODY 2k11.  A series of elements of same type  Placed in contiguous memory locations  Can be individually referenced.
Containers Overview and Class Vector
CNS  Sequences  vector,deque,list,(string),forward_list  Container Adapters  queue, stack, priority_queue  Associative Containers  set, unordered_set.
DATA STRUCTURES AND ALGORITHMS Lecture Notes 12 Prepared by İnanç TAHRALI.
Introduction to STL and the vector container class CS342 Data Structures Based on Ford & Topp.
Main Index Contents 11 Main Index Contents Week 3 – The Vector Container.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 18 Stacks and Queues.
1 Chapter 3 Lists, Stacks, and Queues Abstract Data Types, Vectors Section 3.5, class notes Iterators Generic algorithms.
Chapter 19 C++ Data Structures By C. Shing ITEC Dept Radford University.
Friends & Standard Template Library CSCI3110 Advanced Data Structures Lecturer: Dr. Carroll and Nan Chen.
Queue Queue – First In / First Out (FIFO) data structure that supports two operations: push for adding new element at the end of the queue pop for removing.
Adapted from Data Structures with C++ using STL: Ford, Topp CS 362: Queues Dr. Nazli Mollah Overview of Lecture  Introduction  The Queue ADT  The Radix.
Templates&STL. Computer Programming II 2 Introduction They perform appropriate operations depending on the data type of the parameters passed to them.
Lecture 11 Standard Template Library Lists Iterators Sets Maps.
Lecture 7 : Intro. to STL (Standard Template Library)
Data Structures for Midterm 2. C++ Data Structure Runtimes.
1 Chapter 3 Lists, Stacks, and Queues Reading: Sections 3.1, 3.2, 3.3, 3.4 Abstract Data Types (ADT) Iterators Implementation of Vector.
CSCI 383 Object-Oriented Programming & Design Lecture 25 Martin van Bommel.
Computer Engineering Rabie A. Ramadan Lecture 6.
Collection types CS Chakrabarti Motivation  Thus far the only collection types we have used are vector and matrix  Problem #1: given an input.
Glenn Stevenson CSIS 113A MSJC CSIS 123A Lecture 3 Vectors.
1 Circular, Doubly-Linked Lists Node Composition List Class Pushing and Popping Values Insert and Erase at Arbitrary Locations List Implementation.
CSCI-383 Object-Oriented Programming & Design Lecture 30.
Copyright © Curt Hill STL Priority Queue A Heap-Like Adaptor Class.
Standard Template Library a collection of useful tools.
Kruse/Ryba Ch071 Object Oriented Data Structures Searching STL Vector Sequential Search Binary Search Comparison Trees.
14-1 Computing Fundamentals with C++ Object-Oriented Programming and Design, 2nd Edition Rick Mercer Franklin, Beedle & Associates, 1999 ISBN
1 The Standard Template Library The STL is a collection of Container classes These are class templates for containers. A container is an object that stores.
List Structures What is a list? A homogeneous collection of elements with a linear relationship between the elements linear relationship - each element.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 18: Stacks and Queues.
Mark Redekopp David Kempe
C++ Standard Template Library
Introduction to olympic programming
18 Chapter Stacks and Queues
Chapter 18: Stacks and Queues.
G64ADS Advanced Data Structures
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
COSC160: Data Structures: Lists and Queues
Program based on queue & their operations for an application
Chapter 15 Lists Objectives
Standard Template Library (STL)
Collections Intro What is the STL? Templates, collections, & iterators
Prof. Michael Neary Lecture 7: The STL Prof. Michael Neary
Basic Data Structures.
Abstract Data Types Iterators Vector ADT Sections 3.1, 3.2, 3.3, 3.4
Chapter 19: Stacks and Queues.
Chapter 3 Lists, Stacks, and Queues Abstract Data Types, Vectors
priority_queue<T>
Recursive Linked List Operations
Chapter 17: Linked Lists.
Lists - I The List ADT.
Lists - I The List ADT.
Lecture 8 : Intro. to STL (Standard Template Library)
Evaluation of List Implementations
C++ STL Stack, Queue, and Deque
STL (Standard Template Library)
C++ Programming: chapter 10 – STL
Collections Intro What is the STL? Templates, collections, & iterators
Chapter 3 Lists, Stacks, and Queues
Data Structures & Programming
Presentation transcript:

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. 1D Array Manipulation. 2D Array Manipulation.

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.

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

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; }

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

Stacks

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

Queues

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

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

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