
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++

285 Views
In this article, we will explain the Vizing's theorem and implement it in C++ to color a graph using the Greedy Coloring Algorithm. What is Vizing's Theorem? Vizing's theorem states that for any graph, the minimum number of colors needed to color the edges (chromatic index) is either equal to the maximum degree G of the graph or one more than maximum degree G + 1. The degree of a vertex is the number of edges connected to it. The maximum degree G refer to highest degree for any vertex in the graph. It is ... Read More

725 Views
In this article, we will explain the 4 color problem to color a graph and implement the backtracking algorithm to solve it in C++. The 4 Color Problem The 4-color problem states that the maximum number of colors needed to color any planar graph (or a 2D map) is four, such that no two adjacent nodes have the same color. For example, suppose that you want to color a world map, such that no two countries sharing a border have the same color. According to this theorem, the maximum number of colors needed to do this is four. Now, ... Read More

433 Views
In this article, we will explain the dominating set problem and implement it's solution in C++. First of all, let's understand what a dominating set is. Dominating Set of a Graph A dominating set for a graph is a subset of the set of all the vertices. Every vertex that is not in the dominating set should be adjacent of at least one vertex in the dominating set. To understand this clearly, consider the following graph: In the above graph, the set of vertices {B, D} is one of the dominating sets, because: ... Read More

279 Views
The subsets of a set refers to all the possible combinations of choosing elements from the set. For example, if we have a set {1, 2}, the subsets are {}, {1}, {2}, and {1, 2}. In this article, we will learn how to generate a random subset for a set using coin flipping technique in C++. // Set of elements int arr[] = {1, 2, 3}; // Subsets of the above set {}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3} Coin Flipping Technique The coin flipping technique is a simple way ... Read More

1K+ Views
The subsets of a set refers to all the possible combinations of choosing elements from the set. For example, if we have a set {1, 2}, the subsets are {}, {1}, {2}, and {1, 2}. In this article, we will learn how to generate subsets of a set using the Binary Counting Method in C++. // Set of elements int arr[] = {1, 2, 3}; // Subsets of the above set {}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3} Binary Counting Method The binary counting method is a technique used to generate ... Read More

129 Views
This is a C++ program to implement the Alexander Bogomolny’s UnOrdered Permutation Algorithm for elements from 1 to NAlgorithmsBegin function AlexanderBogomolny() to implement the Algorithms Arguments: Val[] = an array N = number of elements taken as input. K = level Body of the function: intialize l = -1 l = l+1 Val[k] = l if (l == N) Call function display(Val, N) else ... Read More

282 Views
In this article, our task is to find the number of occurrences of a given number using binary search. The binary search algorithm works on the divide-and-conquer principle as it keeps dividing the array in half before searching. To search for an element in an array using binary search, it should be sorted. In the sorted array, we find the middle element and compare it with the element that has to be searched, and based on the comparison, we either search in the left or right sub-array or return the middle element. Following are some example scenarios: Scenario ... Read More

3K+ Views
The memory leak occurs, when a piece of memory which was previously allocated by the programmer. Then it is not deallocated properly by programmer. That memory is no longer in use by the program. So that place is reserved for no reason. That’s why this is called the memory leak.For the memory leak, some block of memory may have wasted. If the system has enough memory, in that case also this may slow down the performance.Examplevoid my_func() { int *data = new int; *data = 50; }Here the problem is *data pointer is never deleted, so memory is ... Read More

6K+ Views
In C we can pass parameters in two different ways. These are call by value, and call by address, In C++, we can get another technique. This is called Call by reference. Let us see the effect of these, and how they work.First we will see call by value. In this technique, the parameters are copied to the function arguments. So if some modifications are done, that will update the copied value, not the actual value.Example#include using namespace std; void my_swap(int x, int y) { int temp; temp = x; x = y; y = ... Read More

8K+ Views
In C or C++, we have used the switch-case statement. In the switch statement we pass some value, and using different cases, we can check the value. Here we will see that we can use ranges in the case statement.The syntax of using range in Case is like below −case low … highAfter writing case, we have to put lower value, then one space, then three dots, then another space, and the higher value.In the following program, we will see what will be the output for the range based case statement.Example#include main() { int data[10] = { 5, ... Read More