mismatch() Function in C++

This C++ program demonstrates the mismatch algorithm. The mismatch algorithm used takes three arguments – the first two arguments are iterators to beginning and end of first container and the third argument is iterator to beginning of second container. The mismatch algorithm returns pair of iterator to the first mismatch of container elements. Here is … Read more

advertisement

count_if() Function in C++

This C++ program demonstrates the count_if algorithm. The count_if takes three arguments – of which the first two are iterators to the beginning and end of the container and the third argument is predicate. The container used here is map which stores name of the companies and their revenue. The predicate checks for companies with … Read more

advertisement

adjacent_find() Function in C++

This C++ program demonstrates the adjacent_find() algorithm. The adjacent_find takes iterator to the beginning and end of a container and an optional predicate as third parameter. The program uses function adjacent_find() to find adjacent pair of elements in which both the elements are same or satisfy boolean true for a predicate passed as a parameter. … Read more

advertisement

find_first_of() Function in C++

This C++ program demonstrates the find_first_of() algorithm. The function find_first_of() finds the first element from first container which exists in second container. The function takes four iterators – iterators to the beginning and end to the sequence containers. Here is the source code of the C++ program which demonstrates the find_first_of() algorithm. The C++ program … Read more

advertisement

find_if() Function in C++

This C++ program demonstrates the find_if algorithm on string vector. The find_if takes three arguments – of which the first two are iterators to the beginning and end of the container and the third argument is predicate. The predicate we are passing returns true on strings starting with ‘P’. Here is the source code of … Read more

advertisement

find() Function in C++

This C++ program creates a vector and uses find() to search for an element. The program creates a vector and uses find() function from algorithm library. The iterator to the beginning and end of the vector is passed as parameter to the function find() and also the key that is to be found. Here is … Read more

advertisement

sort_heap() in C++

This C++ program sorts the heap using sort_heap() operation. The default sort_heap operation sorts the elements of the heap in ascending order. The alternative version of sort_heap can sort the heap depending on the type of predicate and this alternative version takes predicate as its third parameter. The resulting range no longer has the heap … Read more

advertisement

make_heap() in C++

This C++ program creates a heap using make_heap algorithm. A heap is a way to organize the elements of a range that allows for fast retrieval of the element with the highest value at any moment. The make_heap rearranges the elements in the container in such a way that they form a heap. Here is … Read more

advertisement

pop_heap() in C++

This C++ program pops element from heap using pop_heap algorithm. The pop_heap operation swaps the element at first position and the last position and makes the subrange [first, last – 1) into a max-heap. The element at the last position is actually popped from the container. Here is the source code of the C++ program … Read more

advertisement

push_heap() in C++

This C++ program pushes elements to heap using push_heap algorithm. A heap is a way to organize the elements of a range that allows for fast retrieval of the element with the highest value at any moment. The push_heap inserts the elements into the heap at last – 1 position where the heap is defined … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.