Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
C++ Algorithms
Programming with Sikander shorturl.at/rwxUX
Mohammed Sikander
 swap
 max
 min
 max_element
 min_element
 count
 find
 sort
 count_if
 find_if
Mohammed Sikander
Mohammed Sikander
template< class T >
const T& max( const T& a, const T& b );
https://youtu.be/9lBBaAB2H0g
Mohammed Sikander
template< class T >
const T& min( const T& a, const T& b );
https://youtu.be/9lBBaAB2H0g
Mohammed Sikander
template< class ForwardIt >
ForwardIt max_element( ForwardIt first, ForwardIt last );
https://youtu.be/9lBBaAB2H0g
Mohammed Sikander
template< class ForwardIt >
ForwardIt min_element( ForwardIt first, ForwardIt last );
https://youtu.be/9lBBaAB2H0g
Mohammed Sikander
 Find the smallest element in the array and swap with
the first element.
 Find the largest element in the array and swap with the
last element.
 You should use the stl algorithms to find the largest /
smallest element in the array and swap algo to swap
the elements.
Mohammed Sikander
template< class InputIt, class T >
InputIt find( InputIt first, InputIt last, const T& value )
https://youtu.be/FUNs1pRJOso
Mohammed Sikander
template< class InputIt, class T >
int count( InputIt first, InputIt last, const T& value );
https://youtu.be/ASbv3sdmQgE
Mohammed Sikander
Mohammed Sikander
Write code to count the number of occurrences of a given
character, the string is stored in std::string.
Mohammed Sikander
Mohammed Sikander
 Given the string find the character which is occurring
the most number of times.
Mohammed Sikander
template< class RandomIt >
void sort( RandomIt first, RandomIt last );
https://youtu.be/JQ8_IbeUTdA
Mohammed Sikander
template< class RandomIt, class Compare >
void sort( RandomIt first, RandomIt last, Compare comp );
The signature of the comparison function should be equivalent to the following:
bool cmp(const Type1 &a, const Type2 &b);
https://youtu.be/n9SRg4XBd7Y
Mohammed Sikander
 Sort a list of string in ascending order
based on length.
Mohammed Sikander
Mohammed Sikander
 Given a list of numbers, count the
numbers which are prime.
12, 21, 34, 32, 5, 65, 34, 23, 43
Mohammed Sikander
template< class InputIt, class UnaryPredicate >
int count_if( InputIt first, InputIt last, UnaryPredicate p );
https://youtu.be/ASbv3sdmQgE
Mohammed Sikander
template< class InputIt, class UnaryPredicate >
InputIt find_if( InputIt first, InputIt last, UnaryPredicate p );
Mohammed Sikander
 Given an array of numbers, find all the
numbers which are prime and print them
on screen.
 Use find_if to find the next prime number
in array.
Mohammed Sikander
Mohammed Sikander
Thank you

More Related Content

Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj