SlideShare a Scribd company logo
STL Algorithms
Presented by: ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is STL? ,[object Object],[object Object],[object Object],[object Object]
Uses of STL – Why should it be used? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The three parts of STL   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Introduction to STL Algorithms ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The sort() function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> void  main() { int  arr[10]={2,4,1,5,6,7,-11,23,9,-1999}; for (int a=0;a<10;a++) { cout <<arr[a]<<&quot;&quot;; } cout <<endl; sort (arr,arr+10); for (a=0;a<10;a++) { cout<<arr[a]<<&quot;&quot;;; } }
Extended Example #include<algorithm> #include<iostream.h> #include<list.h> using namespace std; void main() { list <int>  dc,dc2; dc.push_back(9); dc.push_back(10); dc.push_back(-11); dc2=dc; while(! dc.empty() ) { cout<<dc.front(); dc.pop_front(); cout<<endl; } dc2.sort(); cout<<endl; while(! dc2.empty() ) { cout<<dc2.front(); dc2.pop_front(); cout<<endl; } }
The rotate() function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> int  arr[10]={1,2,3,4,5,6,7,8,9,10}; rotate (arr,arr+4,arr+10); for ( int  a=0;a<10;a++) { cout <<arr[a]<<&quot;&quot;; } cout <<endl; [ Output will be “ 5 6 7 8 9 10 1 2 3 4 5”]
The rotate_copy() function ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The reverse() function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> char  arr[5]={'a','b','c','d','e'}; reverse (arr,arr+5); for (int a=0;a<5;a++) { cout <<arr[a]<<&quot;&quot;; } cout <<endl; [Output will be “e d c b a”]
Extended Example #include<algorithm> #include<iostream.h> #include<list.h> #include<vector.h> using namespace std; void main() { vector <int> v; vector <int> ::iterator it; v.push_back(10); v.push_back(11); v.push_back(12); v.push_back(13); v.push_back(14); v.push_back(15); for(it=v.begin();it!=v.end();it++) { cout<<*it<<&quot; &quot;; } cout<<endl; reverse(v.begin(),v.end()); cout<<endl; for(it=v.begin();it!=v.end();it++) { cout<<*it<<&quot; &quot;; } }
The random shuffle() function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> char  arr[5]={'a','b','c','d','e'}; random_shuffle (arr,arr+5); for (int a=0;a<5;a++) { cout <<arr[a]<<&quot;&quot;; } cout <<endl; [Output can be “e b d c a”]
Extended Example #include<algorithm> #include<iostream.h> #include<vector.h> using namespace std; void main() { vector <int> v; vector <int> ::iterator it; v.push_back(1); v.push_back(2); v.push_back(3); v.push_back(4); v.push_back(5); v.push_back(6); v.push_back(7); v.push_back(8); v.push_back(9); v.push_back(10); for(it=v.begin();it!=v.end();it++) { cout<<*it<<&quot; &quot;; } cout<<endl; random_shuffle(v.begin(),v.end()); cout<<endl; for(it=v.begin();it!=v.end();it++) { cout<<*it<<&quot; &quot;; }
The find function ,[object Object],[object Object],[object Object],An example : #include <iostream> #include <algorithm> void  main() {   c har  arr[20]=&quot;abcdefgh&quot;; char  *p; p= find (arr,arr+7,'d'); puts (p); }
The replace function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> void  main() { char  arr[20]=&quot;faizansuhail&quot;; replace (arr,&arr[10],'a','b'); puts (arr); }
The fill function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> void  main() { int  ar[20]={23,45,56,4,45,23}; fill (ar,ar+5,45); for (int a=0;a<5;a++) cout <<&quot;&quot;<<ar[a]; }
The remove function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> void  main() { char  arr[20]=&quot;abcdefgh&quot;; char  *p; p= remove (arr,&arr[7],'h'); puts (p); }
The search function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> void   main() { char  source[20]=&quot;abcdefgh&quot;; char  tar[20]=&quot;fgh&quot;,*p; p= search (source,&source[7],tar,&tar[2]); if (*p==source[7]) { cout <<&quot;not found&quot;; } else  { puts (p); cout <<&quot;found&quot;; } }
The swap function ,[object Object],[object Object],[object Object]
An example : #include <iostream> #include <algorithm> #include  <vector> void   main() { vector <int> obj; vector <int> tar; obj.push_back(1); obj.push_back(2); obj.push_back(3); tar.push_back(4); tar.push_back(5); tar.push_back(6); swap(obj,tar); cout<<obj[0]; cout<<obj[1]; cout<<obj[2]; cout<<tar[0]; cout<<tar[1]; cout<<tar[2];} }
The swap ranges function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> #include  <vector> void   main() { void  main() { int  arr[]={1,2,3,4,5,6}; int  tar[]={6,7,8,9,10,11,12}; swap_ranges(arr,arr+6,tar); for (int a=0;a<5;a++) { cout<<&quot;&quot;<<arr[a]; } } }
The count function ,[object Object],[object Object]
An example : #include <iostream> #include <algorithm> #include  <vector> void   main() { int  a; int  arr[]={1,2,3,4,5,6,7}; a=mycount(&arr[0],&arr[7],7); cout<<&quot;7 come&quot;; cout<<&quot;&quot;; cout<<a; cout<<&quot;times&quot;; cout<<&quot;************************&quot;; } int  mycount(int *p,int *q,int b) { int  a=0; while (p!=q) { if (*p++==7) { a++; } } return  a; }
The minimum function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> #include  <vector> void   main() { int  *a; char  *p; int  arr[]={1,2,3,4,5,6,7}; char  tar[]={'a','b','c','d'}; a= min_element (arr,arr+7); p= min_element (tar,tar+4); cout<<&quot;&quot;; cout<<*a; cout<<&quot;&quot;; cout<<*p; cout<<&quot;&quot;; }
The maximum function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> #include  <vector> void   main() { int  *a; char   *p; int   arr[]={1,2,3,4,5,6,7}; char  tar[]={'a','b','c','d'}; a= max_element (arr,arr+7); p= max_element (tar,tar+4); cout<<&quot;&quot;; cout<<*a; cout<<&quot;&quot;; cout<<*p; cout<<&quot;&quot;;}
The equal function ,[object Object],[object Object]
An example : #include <iostream> #include <algorithm> #include  <vector> void   main() { int  arr[]={1,2,3,4,5}; int  brr[]={1,2,3,4,5}; int  crr[]={1,2,3,4,1}; if (equal(arr,arr+5,brr)) { cout<<&quot;ok&quot;; } else { cout<<&quot;not ok&quot;; } if (equal(arr,arr+5,crr)) { cout<<&quot;ok&quot;; } else { cout<<&quot;not ok&quot;; }
The for_each() function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> void   main() { myfunction (int i) { i=i+2 } void  main() { int  arr[]={1,2,3,4,5}; for_each(arr,arr+5,myfunction); cout<<&quot;&quot;<<arr; }
The find_if() function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> void   main() { bool  iseven(int i) { if(i%2==0) return  true; else  return  false } void  main() { int  arr[]={1,2,3,4,5}; it =find_if(arr,arr+5,iseven); cout<<&quot;&quot;<<*it;}
The binary search() function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> void   main() { int arr[ ]={1,2,3,4,5}; int *it; bool a; a=binary_search(arr,arr+5,4); cout<<a; }
The merge function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> void main() { int arr[]={1,2,3,4,5}; int brr[]={6,7,8,9,10}; int crr[10]; merge(arr,arr+5,brr,brr+5,crr); for(int a=0;a<10;a++) { cout<<crr[a]; } }
The copy function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> void main() { int arr[   ]={1,2,3,4,5};   int crr[10]; copy  (arr,arr+5,crr); for(int a=0;a< 5 ;a++) { cout<<crr[a] <<“” ; } }
The lexographical function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> void  main() { string a=“pakistan”; string b=“waziristan”; if(lexographical_compare(a, a+7, b, b+9)) cout<<“sab sey pehle Pakistan”<<endl }
The make_heap function ,[object Object],[object Object],[object Object],[object Object],An example : #include <iostream> #include <algorithm> void  main() {   int arr[10]={1,2,3,4,5,6,7,8,9}; for(int a=0;a<10;a++) { cout<<arr[a]<<&quot;&quot;; } cout<<endl; make_heap(arr, &arr[9]); for(a=0;a<10;a++) { cout<<arr[a]<<&quot;&quot;;; } }
The push_heap function ,[object Object],[object Object],[object Object],[object Object],An example : #include <iostream> #include <algorithm> void  main() {   int arr[10]={1,2,3,4,5,6,7,8,9}; make_heap(arr, &arr[9]); arr[9]=31; push_heap(arr, &arr[10]); for(a=0;a<10;a++) { cout<<arr[a]<<&quot;&quot;;; }
The pop_heap function ,[object Object],[object Object],[object Object],[object Object],An example : #include <iostream> #include <algorithm> void  main() { int arr[10]={1,2,3,4,5,6,7,8,9}; make_heap (arr, &arr[9]); pop_heap(arr, &arr[8]); for(int a=0;a<10;a++) { cout<<arr[a]<<&quot;&quot;;; }
The sort_heap function ,[object Object],[object Object],An example : #include <iostream> #include <algorithm> void  main() { int arr[10]={1,2,3,4,5,6,7,8,9}; make_heap(arr, arr[8]); arr[9]=31; push_heap(arr,&arr[9]); for(a=0;a<10;a++) { cout<<arr[a]<<&quot;&quot;;; }
Q&A Session

More Related Content

What's hot

Io streams
Io streamsIo streams
pandas - Python Data Analysis
pandas - Python Data Analysispandas - Python Data Analysis
pandas - Python Data Analysis
Andrew Henshaw
 
Stack_Data_Structure.pptx
Stack_Data_Structure.pptxStack_Data_Structure.pptx
Stack_Data_Structure.pptx
sandeep54552
 
Lecture 6: linked list
Lecture 6:  linked listLecture 6:  linked list
Lecture 6: linked list
Vivek Bhargav
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)
Naman Joshi
 
A presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmA presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithm
Gaurav Kolekar
 
Data Structures with C Linked List
Data Structures with C Linked ListData Structures with C Linked List
Data Structures with C Linked List
Reazul Islam
 
Python strings
Python stringsPython strings
Python strings
Mohammed Sikander
 
Python strings presentation
Python strings presentationPython strings presentation
Python strings presentation
VedaGayathri1
 
Expression trees
Expression treesExpression trees
Expression trees
Salman Vadsarya
 
Sets in python
Sets in pythonSets in python
Function arguments In Python
Function arguments In PythonFunction arguments In Python
Function arguments In Python
Amit Upadhyay
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
Tech_MX
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
vaibhav2910
 
Automata theory - NFA ε to DFA Conversion
Automata theory - NFA ε to DFA ConversionAutomata theory - NFA ε to DFA Conversion
Automata theory - NFA ε to DFA Conversion
Akila Krishnamoorthy
 
Primitive data types in java
Primitive data types in javaPrimitive data types in java
Primitive data types in java
Umamaheshwariv1
 
Pilas
PilasPilas
Pilas
Neill Diaz
 
Stacks
StacksStacks
Data Structures Chapter-4
Data Structures Chapter-4Data Structures Chapter-4
Data Structures Chapter-4
priyavanimurugarajan
 
Standard data-types-in-py
Standard data-types-in-pyStandard data-types-in-py
Standard data-types-in-py
Priyanshu Sengar
 

What's hot (20)

Io streams
Io streamsIo streams
Io streams
 
pandas - Python Data Analysis
pandas - Python Data Analysispandas - Python Data Analysis
pandas - Python Data Analysis
 
Stack_Data_Structure.pptx
Stack_Data_Structure.pptxStack_Data_Structure.pptx
Stack_Data_Structure.pptx
 
Lecture 6: linked list
Lecture 6:  linked listLecture 6:  linked list
Lecture 6: linked list
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)
 
A presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmA presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithm
 
Data Structures with C Linked List
Data Structures with C Linked ListData Structures with C Linked List
Data Structures with C Linked List
 
Python strings
Python stringsPython strings
Python strings
 
Python strings presentation
Python strings presentationPython strings presentation
Python strings presentation
 
Expression trees
Expression treesExpression trees
Expression trees
 
Sets in python
Sets in pythonSets in python
Sets in python
 
Function arguments In Python
Function arguments In PythonFunction arguments In Python
Function arguments In Python
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
 
Automata theory - NFA ε to DFA Conversion
Automata theory - NFA ε to DFA ConversionAutomata theory - NFA ε to DFA Conversion
Automata theory - NFA ε to DFA Conversion
 
Primitive data types in java
Primitive data types in javaPrimitive data types in java
Primitive data types in java
 
Pilas
PilasPilas
Pilas
 
Stacks
StacksStacks
Stacks
 
Data Structures Chapter-4
Data Structures Chapter-4Data Structures Chapter-4
Data Structures Chapter-4
 
Standard data-types-in-py
Standard data-types-in-pyStandard data-types-in-py
Standard data-types-in-py
 

Viewers also liked

The Style of C++ 11
The Style of C++ 11The Style of C++ 11
The Style of C++ 11
Sasha Goldshtein
 
Idiomatic C++
Idiomatic C++Idiomatic C++
Idiomatic C++
Federico Ficarelli
 
Distributed Systems Design
Distributed Systems DesignDistributed Systems Design
Distributed Systems Design
Dennis van der Stelt
 
Improving The Quality of Existing Software
Improving The Quality of Existing SoftwareImproving The Quality of Existing Software
Improving The Quality of Existing Software
Steven Smith
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
farhan amjad
 
C++ Advanced
C++ AdvancedC++ Advanced
C++ Advanced
Vivek Das
 
Web Service Basics and NWS Setup
Web Service  Basics and NWS SetupWeb Service  Basics and NWS Setup
Web Service Basics and NWS Setup
Northeastern University
 
Bjarne Stroustrup - The Essence of C++: With Examples in C++84, C++98, C++11,...
Bjarne Stroustrup - The Essence of C++: With Examples in C++84, C++98, C++11,...Bjarne Stroustrup - The Essence of C++: With Examples in C++84, C++98, C++11,...
Bjarne Stroustrup - The Essence of C++: With Examples in C++84, C++98, C++11,...
Complement Verb
 
Operator overloading
Operator overloading Operator overloading
Operator overloading
Northeastern University
 
An Introduction to Part of C++ STL
An Introduction to Part of C++ STLAn Introduction to Part of C++ STL
An Introduction to Part of C++ STL
乐群 陈
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo design
Confiz
 
SOLID Principles part 2
SOLID Principles part 2SOLID Principles part 2
SOLID Principles part 2
Dennis van der Stelt
 
Programming In C++
Programming In C++ Programming In C++
Programming In C++
shammi mehra
 
SOLID Principles part 1
SOLID Principles part 1SOLID Principles part 1
SOLID Principles part 1
Dennis van der Stelt
 
Exception handling and templates
Exception handling and templatesException handling and templates
Exception handling and templates
farhan amjad
 
Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)
farhan amjad
 
Memory Management In C++
Memory Management In C++Memory Management In C++
Memory Management In C++
ShriKant Vashishtha
 
Building Embedded Linux
Building Embedded LinuxBuilding Embedded Linux
Building Embedded Linux
Sherif Mousa
 
Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++
Liju Thomas
 
Keys to Continuous Delivery Success - Mark Warren, Product Director, Perforc...
Keys to Continuous  Delivery Success - Mark Warren, Product Director, Perforc...Keys to Continuous  Delivery Success - Mark Warren, Product Director, Perforc...
Keys to Continuous Delivery Success - Mark Warren, Product Director, Perforc...
Perforce
 

Viewers also liked (20)

The Style of C++ 11
The Style of C++ 11The Style of C++ 11
The Style of C++ 11
 
Idiomatic C++
Idiomatic C++Idiomatic C++
Idiomatic C++
 
Distributed Systems Design
Distributed Systems DesignDistributed Systems Design
Distributed Systems Design
 
Improving The Quality of Existing Software
Improving The Quality of Existing SoftwareImproving The Quality of Existing Software
Improving The Quality of Existing Software
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
C++ Advanced
C++ AdvancedC++ Advanced
C++ Advanced
 
Web Service Basics and NWS Setup
Web Service  Basics and NWS SetupWeb Service  Basics and NWS Setup
Web Service Basics and NWS Setup
 
Bjarne Stroustrup - The Essence of C++: With Examples in C++84, C++98, C++11,...
Bjarne Stroustrup - The Essence of C++: With Examples in C++84, C++98, C++11,...Bjarne Stroustrup - The Essence of C++: With Examples in C++84, C++98, C++11,...
Bjarne Stroustrup - The Essence of C++: With Examples in C++84, C++98, C++11,...
 
Operator overloading
Operator overloading Operator overloading
Operator overloading
 
An Introduction to Part of C++ STL
An Introduction to Part of C++ STLAn Introduction to Part of C++ STL
An Introduction to Part of C++ STL
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo design
 
SOLID Principles part 2
SOLID Principles part 2SOLID Principles part 2
SOLID Principles part 2
 
Programming In C++
Programming In C++ Programming In C++
Programming In C++
 
SOLID Principles part 1
SOLID Principles part 1SOLID Principles part 1
SOLID Principles part 1
 
Exception handling and templates
Exception handling and templatesException handling and templates
Exception handling and templates
 
Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)
 
Memory Management In C++
Memory Management In C++Memory Management In C++
Memory Management In C++
 
Building Embedded Linux
Building Embedded LinuxBuilding Embedded Linux
Building Embedded Linux
 
Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++
 
Keys to Continuous Delivery Success - Mark Warren, Product Director, Perforc...
Keys to Continuous  Delivery Success - Mark Warren, Product Director, Perforc...Keys to Continuous  Delivery Success - Mark Warren, Product Director, Perforc...
Keys to Continuous Delivery Success - Mark Warren, Product Director, Perforc...
 

Similar to STL ALGORITHMS

Object Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptxObject Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptx
RashidFaridChishti
 
Synapse india complain sharing info on chapter 8 operator overloading
Synapse india complain sharing info on chapter 8   operator overloadingSynapse india complain sharing info on chapter 8   operator overloading
Synapse india complain sharing info on chapter 8 operator overloading
SynapseindiaComplaints
 
The STL
The STLThe STL
The STL
adil raja
 
Bw14
Bw14Bw14
Lecture5
Lecture5Lecture5
Lecture5
ravifeelings
 
computer notes - Data Structures - 8
computer notes - Data Structures - 8computer notes - Data Structures - 8
computer notes - Data Structures - 8
ecomputernotes
 
Java 5 Features
Java 5 FeaturesJava 5 Features
Java 5 Features
sholavanalli
 
Arrays
ArraysArrays
Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
emailharmeet
 
C++ STL 概觀
C++ STL 概觀C++ STL 概觀
C++ STL 概觀
PingLun Liao
 
Practical Meta Programming
Practical Meta ProgrammingPractical Meta Programming
Practical Meta Programming
Reggie Meisler
 
Unit 4
Unit 4Unit 4
Unit 4
siddr
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
Yaser Zhian
 
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingDynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Meghaj Mallick
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#
Shahzad
 
Bt0065
Bt0065Bt0065
Bt0065
Simpaly Jha
 
B T0065
B T0065B T0065
B T0065
Simpaly Jha
 
Python 3000
Python 3000Python 3000
Python 3000
Alexandro Colorado
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
Abhishek Tirkey
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
GauravPandey43518
 

Similar to STL ALGORITHMS (20)

Object Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptxObject Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptx
 
Synapse india complain sharing info on chapter 8 operator overloading
Synapse india complain sharing info on chapter 8   operator overloadingSynapse india complain sharing info on chapter 8   operator overloading
Synapse india complain sharing info on chapter 8 operator overloading
 
The STL
The STLThe STL
The STL
 
Bw14
Bw14Bw14
Bw14
 
Lecture5
Lecture5Lecture5
Lecture5
 
computer notes - Data Structures - 8
computer notes - Data Structures - 8computer notes - Data Structures - 8
computer notes - Data Structures - 8
 
Java 5 Features
Java 5 FeaturesJava 5 Features
Java 5 Features
 
Arrays
ArraysArrays
Arrays
 
Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
 
C++ STL 概觀
C++ STL 概觀C++ STL 概觀
C++ STL 概觀
 
Practical Meta Programming
Practical Meta ProgrammingPractical Meta Programming
Practical Meta Programming
 
Unit 4
Unit 4Unit 4
Unit 4
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
 
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingDynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#
 
Bt0065
Bt0065Bt0065
Bt0065
 
B T0065
B T0065B T0065
B T0065
 
Python 3000
Python 3000Python 3000
Python 3000
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 

Recently uploaded

BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 

Recently uploaded (20)

BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 

STL ALGORITHMS

  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. Extended Example #include<algorithm> #include<iostream.h> #include<list.h> using namespace std; void main() { list <int> dc,dc2; dc.push_back(9); dc.push_back(10); dc.push_back(-11); dc2=dc; while(! dc.empty() ) { cout<<dc.front(); dc.pop_front(); cout<<endl; } dc2.sort(); cout<<endl; while(! dc2.empty() ) { cout<<dc2.front(); dc2.pop_front(); cout<<endl; } }
  • 9.
  • 10.
  • 11.
  • 12. Extended Example #include<algorithm> #include<iostream.h> #include<list.h> #include<vector.h> using namespace std; void main() { vector <int> v; vector <int> ::iterator it; v.push_back(10); v.push_back(11); v.push_back(12); v.push_back(13); v.push_back(14); v.push_back(15); for(it=v.begin();it!=v.end();it++) { cout<<*it<<&quot; &quot;; } cout<<endl; reverse(v.begin(),v.end()); cout<<endl; for(it=v.begin();it!=v.end();it++) { cout<<*it<<&quot; &quot;; } }
  • 13.
  • 14. Extended Example #include<algorithm> #include<iostream.h> #include<vector.h> using namespace std; void main() { vector <int> v; vector <int> ::iterator it; v.push_back(1); v.push_back(2); v.push_back(3); v.push_back(4); v.push_back(5); v.push_back(6); v.push_back(7); v.push_back(8); v.push_back(9); v.push_back(10); for(it=v.begin();it!=v.end();it++) { cout<<*it<<&quot; &quot;; } cout<<endl; random_shuffle(v.begin(),v.end()); cout<<endl; for(it=v.begin();it!=v.end();it++) { cout<<*it<<&quot; &quot;; }
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21. An example : #include <iostream> #include <algorithm> #include <vector> void main() { vector <int> obj; vector <int> tar; obj.push_back(1); obj.push_back(2); obj.push_back(3); tar.push_back(4); tar.push_back(5); tar.push_back(6); swap(obj,tar); cout<<obj[0]; cout<<obj[1]; cout<<obj[2]; cout<<tar[0]; cout<<tar[1]; cout<<tar[2];} }
  • 22.
  • 23.
  • 24. An example : #include <iostream> #include <algorithm> #include <vector> void main() { int a; int arr[]={1,2,3,4,5,6,7}; a=mycount(&arr[0],&arr[7],7); cout<<&quot;7 come&quot;; cout<<&quot;&quot;; cout<<a; cout<<&quot;times&quot;; cout<<&quot;************************&quot;; } int mycount(int *p,int *q,int b) { int a=0; while (p!=q) { if (*p++==7) { a++; } } return a; }
  • 25.
  • 26.
  • 27.
  • 28. An example : #include <iostream> #include <algorithm> #include <vector> void main() { int arr[]={1,2,3,4,5}; int brr[]={1,2,3,4,5}; int crr[]={1,2,3,4,1}; if (equal(arr,arr+5,brr)) { cout<<&quot;ok&quot;; } else { cout<<&quot;not ok&quot;; } if (equal(arr,arr+5,crr)) { cout<<&quot;ok&quot;; } else { cout<<&quot;not ok&quot;; }
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.