
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

422 Views
To check if a graph is strongly connected or not, we need to check if for any pair of vertices u and v in the directed graph, there exists a directed path from u to v and a directed path from v to u. In this article, we have a directed graph with five vertices and its respective adjacency matrix. Our task is to check if the given graph is strongly connected or not. Example of Strongly Connected Graph The graph displayed in the figure below is an example of a strongly connected graph. In the above graph, ... Read More

766 Views
To check if a directed graph is connected or not, we need to check if there exists a path between every pair of vertices. A directed graph (or digraph) is a graph where each edge has a direction, edges are in ordered pairs, and edges traverse from the source vertex (the tail) to the destination vertex (the head). In this article, we have a directed graph with five vertices and its respective adjacency matrix. Our task is to use Depth-first Search(DFS) to check the connectivity of the given graph. Example of Connected Graph In the figure given below, we have ... Read More

1K+ Views
The interpolation search is an improved version of the binary search. The list is divided using the mid element in the binary search whereas the interpolation search algorithm tries to locate the exact position using the interpolation formula. For this algorithm to work properly, the data collection should be in a sorted form and equally distributed. In this article, we have a sorted array. Our task is to implement the interpolation search algorithm algorithm on this sorted array in C++. The formula used in this algorithm to find the position is given below: Interpolation Position Search Formula pos = ... Read More

4K+ Views
Counting sort is a stable and non-comparison-based sorting technique, that is used to sort the objects according to the keys that are small integers. It counts the number of keys whose key values are same. It works by counting the occurrences of elements in the array. This sorting technique is efficient when difference between different keys are not so big, otherwise it can increase the space complexity. In this article, we have an unsorted array. Our task is to implement the counting sort algorithm to sort the given unsorted array in C++. Example Here is an example of ... Read More

2K+ Views
The shell sorting technique is based on the insertion sort. In the insertion sort, sometimes we need to shift a large block to insert an item in the correct position. In shell sort, we avoid large number of shifting. The sorting is done with specific interval. After each pass, the interval is reduced to make smaller interval. We call also say we use gapped insertion sort in shell sort as we compare elements separated by a gap. In this article, we have an unsorted array. Our task is to sort the given unsorted array by implementing the shell sort in ... Read More

19K+ Views
The insertion sort technique is an in-place comparison-based sorting algorithm used to sort the numbers in an ascending or descending order. It is similar to the card sorting technique. In this technique, we pick up one element from the data set and shift the data elements to make a place to insert the picked-up element into the data set. In this article, we have an array of integers. Our task is to implement insertion sort in C++ to sort the given array. Example Here is an example of an array before sorting and after sorting using insertion sort: ... Read More

22K+ Views
The selection sort is an in-place comparison-based simple sorting algorithm. In the selection sort technique, the list is divided into two parts: sorted and unsorted. The minimum element from the unsorted part is selected and swapped with the element at the beginning of the list. Similarly, the next minimum value from the unsorted list is placed at the next position in the sorted list, and this keeps repeating until the whole array is sorted. In this article, we have an unsorted array. Our task is to sort this array using selection sort in C++. Here is an example of selection ... Read More

46K+ Views
The merge sort technique is based on the divide and conquer technique. We divide the whole data set into smaller parts and merge them into a larger piece in sorted order. It is also very effective for worst cases because this algorithm has lower time complexity for worst cases too. In this article, we have an unsorted array of integers and our task is to implement the merge sort to sort the unsorted array. Steps to to Implement Merge Sort We will be using the steps mentioned below to implement the merge sort algorithm: ... Read More

1K+ Views
The Heap Sort is a comparison-based sorting algorithm that sorts the numbers using a binary heap. It is an in-place sorting method, that means it sorts the array without needing any extra space. In this article, we have been given an unsorted array and our task is to implement the heap sort in C++. What is Heap Sort? The heap sort is an efficient sorting technique that first constructs the heap ADT and then removes the root element to swap it with the node having minimum value at the leaf position. Then we use the heapify method ... Read More

17K+ Views
Bubble sort is comparison based sorting algorithm. It works by going through the list, comparing each pair of numbers, and swapping them if they are in the wrong order. This process is repeated until the list is sorted. The name "bubble sort" comes from the way smaller numbers move to the front of the list, like bubbles rising to the top. While bubble sort is easy to understand, it is not the most efficient way to sort numbers. Other sorting methods, like insertion sort, tend to work faster and handle larger lists better. One good thing about bubble ... Read More