Skip to content

Tag Archives: cpp-algorithm-library

std::swap is used for swapping of elements between two containers. One of its variation is std::swap_ranges, which as the name suggests is used for swapping… Read More
upper_bound() is a standard library function in C++ defined in the header . It returns an iterator pointing to the first element in the range… Read More
std::nth_element() is an STL algorithm which rearranges the list in such a way such that the element at the nth position is the one which… Read More
For calculating the smallest of all the elements in a given list, we have std::min, but what if we want to find the smallest not… Read More
We have std::max to find maximum of 2 or more elements, but what if we want to find the largest element in an array or… Read More
std::max is defined in the header file <algorithm> and is used to find out the largest of the number passed to it. It returns the… Read More
std::is_sorted_until is used to find out the first unsorted element in the range [first, last). It returns an iterator to the first unsorted element in… Read More
std::min is defined in the header file and is used to find out the smallest of the number passed to it. It returns the first… Read More
std::equal() helps to compares the elements within the range [first_1,last_1) with those within range beginning at first_2. Syntax 1: template bool equal (InputIterator1 first1, InputIterator1… Read More
Prerequisite: std::search std::search_n is an STL algorithm defined inside the header file , which is used to search whether a given element satisfies a predicate… Read More
std::generate is an STL algorithm, which is used to generate numbers based upon a generator function, and then, it assigns those values to the elements… Read More
std::generate, as the name suggests is an STL algorithm, which is used to generate numbers based upon a generator function, and then, it assigns those… Read More
std::search is defined in the header file <algorithm> and used to find out the presence of a subsequence satisfying a condition (equality if no such… Read More
The lower_bound() method in C++ is used to return an iterator pointing to the first element in the range [first, last) which has a value… Read More
Moves the elements in the range [first,last] starting from the end into the range terminating at result. The function begins by moving *(last-1) into *(result-1),… Read More