C++ Articles - Page 655 of 719

C++ Program to Implement Prev_Permutataion in STL

Farhan Muhamed
Updated on 09-May-2025 15:39:04

195 Views

The Prev permutation is an algorithmic operation that rearranges the elements of an array or a range of an array into the previous lexicographically smaller permutation. In this article, we will learn how to use the prev_permutation() function from the Standard Template Library (STL) in C++. What is Prev Permutation? The Prev Permutation is an operation used to generate all the possible permutations of an array in reverse lexicographical order. A permutation is one of the N! arrangements of the elements in an array of size N. The STL library of C++ provide a pre-defined function for performing the ... Read More

C++ Program to Implement Pairs in STL

Farhan Muhamed
Updated on 09-May-2025 15:38:46

481 Views

A pair is a container provided by the Standard Template Library (STL) in C++ that stores two heterogeneous objects as a single unit. In this article, we will learn how to use a pair from the Standard Template Library (STL) in C++. What is Pair? Pair is a utility container defined in the header that is used to store two related data elements or objects in pairs. The first element will be referenced as first, and the second element will be referenced as second. It is commonly used to return two values from a function using a single ... Read More

C++ Program to Implement Next_Permutation in STL

Farhan Muhamed
Updated on 09-May-2025 15:38:15

461 Views

Next permutation is an algorithmic operation that rearranges the elements of a range into the next lexicographically greater permutation. In this article, we will learn how to use the next_permutation() function from the Standard Template Library (STL) in C++. What is Next Permutation? The Next Permutation is an operation used to generate all the possible permutations an array in lexicographical order. A permutation is the one of N! arrangements of the elements in an array of size N. If the current sequence is the last permutation, the function transforms it into the first one (i.e., sorted in ascending order). ... Read More

C++ Program to Implement Multiset in STL

Farhan Muhamed
Updated on 07-May-2025 18:29:43

288 Views

A multiset is an associative container that stores data in a sorted order in such a way that it allows duplicate values in the set. In this article, we will learn how to use a multiset from the Standard Template Library (STL) in C++. What is Multiset? Multiset is a sorted associative container that allows storing multiple elements with the same value. The values are automatically arranged in sorted order. This makes it useful in scenarios where you need to keep count of repeated values while maintaining order. For example, we can store the scores of students even ... Read More

C++ Program to Implement Multimap in STL

Farhan Muhamed
Updated on 07-May-2025 18:29:29

452 Views

A multimap is an associative container that stores elements in a key-value pair format, where multiple values can share the same key. In this article, we will learn how to use a multimap from the Standard Template Library (STL) in C++. What is Multimap? Multimap is a sorted associative container that stores data in key-value pairs, where keys can occur multiple times. Keys are stored in sorted order, and you can insert, access, and remove elements based on the key. For example, in a multimap we can store student names with their scores even if some students have ... Read More

C++ Program to Implement Map in STL

Farhan Muhamed
Updated on 07-May-2025 18:29:15

4K+ Views

A map is an associative container that stores elements in a key-value pair format. Each element has a unique key and a corresponding mapped value. No two mapped values can have the same key. In this article, we will learn how to use a map from the Standard Template Library (STL) in C++. What is Map? Map is a sorted associative container that contains key-value pairs with unique keys. Keys are sorted automatically, and each key is associated with a value. You can insert, access, and remove elements based on the key. For example, we can store ... Read More

C++ Program to Implement List in STL

Farhan Muhamed
Updated on 06-May-2025 18:21:17

423 Views

A List in C++ STL library is hardcoded implementation of a doubly linked list data structure. In this article, we will learn how to implement and use a list in C++ . What is List? List is a doubly linked container provided in the C++ STL library, in which each element points to both its previous and next elements. Meaning, in this list we can quickly traverse in both forward and backward direction using pointers just like a doubly linked list. Compared to vectors or arrays, these lists allow fast insertions and deletions from the middle of the sequence. ... Read More

C++ Program to Implement Forward_List in STL

Farhan Muhamed
Updated on 06-May-2025 18:20:36

279 Views

Forward List is a type of singly linked list available in the C++ STL (Standard Template Library). In this artcile, we will learn how to use forward_list from C++ STL library. What is Forward List? Forward list is a linear data structure which allows traversal only in one direction. It is similar to a singly linked list where each element points to the next element and moves in forward direction. It supports operations like insertion, deletion, and traversal from the beginning to end but not in reverse direction. The insertion and deletion operations are comparatively very fast in ... Read More

C++ Program to Implement Deque in STL

Farhan Muhamed
Updated on 06-May-2025 18:20:01

455 Views

Deque or Double Ended Queue is a special type of queue where we can insert and delete elements from both front and back. In this article, we will learn how to use deque from C++ STL (Standard Template Library). What is Deque? Deque is a linear data structure in which the insertion and deletion operations can be performed at both the ends (front and rear). Meaning, the data can be inserted at both front and rear positions and can be deleted from both front and rear positions. This gives more flexibility compared to a normal queue which supports only ... Read More

Binary Search functions in C++ STL

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

1K+ Views

Binary search is a search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the sorted array. The time complexity of binary search is O(1). This is a C++ program in which we implement various. Binary Search functions in C++ STLAlgorithmBegin    Initialize the vector of integer values.    The functions are used here:    binary_search(start_pointer, end_pointer, value) = Returns true if the value present in array otherwise    false.    lower_bound(start_pointer, end_pointer, value) = Returns pointer to “position of value” if container ... Read More

Advertisements