- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 7346 Articles for C++
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
184 Views
A bipartite graph is a graph in which if the graph coloring is possible using two colors i.e.; vertices in a set are colored with the same color. This is a C++ program to Check whether a graph bipartite or not using DFS.AlgorithmBegin 1. An array color[] is used to stores 0 or 1 for every node which denotes opposite colors. 2. Call function DFS from any node. 3. If the node w has not been visited previously, then assign ! color[v] to color[w] and call DFS again to visit nodes connected to w. ... Read More
![Paul Richard](https://www.tutorialspoint.com/assets/profiles/13505/profile/60_52698-1512536733.jpg)
605 Views
A bipartite graph is a graph in which if the graph coloring is possible using two colors i.e; vertices in a set are colored with the same color. This is a C++ program to Check whether a graph bipartite or not using BFS.AlgorithmBegin Function Bipartite(): 1) Assign a color to the source vertex 2) Color all the neighbors with another color except first one color. 3) Color all neighbor’s neighbor with First color. 4) Like this way, assign color to all vertices such that it satisfies all the constraints of k way coloring problem where ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
217 Views
A bipartite graph is a graph in which if the graph coloring is possible using two colors i.e.; vertices in a set are colored with the same color. This is a C++ program to Check whether a graph bipartite or not using 2 color algorithm.Functions and pseudocodesBegin 1. Develop function isSafe() to check if the current color assignment is safe for vertex v, i.e. checks whether the edge exists or not. If it exists, then next check whether the color to be filled in the new vertex is already used ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
185 Views
If a directed graph is given, determine if a vertex j is reachable from another vertex i for all vertex pairs (i, j) in the given graph. Reachable mean that there is a path from vertex i to j. This reach-ability matrix is called transitive closure of a graph. Warshall algorithm is commonly used to find the Transitive Closure of a Given Graph G. Here is a C++ program to implement this algorithm.AlgorithmBegin 1. Take maximum number of nodes as input. 2. For Label the nodes as a, b, c….. 3. To check if there any edge ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
177 Views
In this Program we will basically find a feedback arc set which contains edges which when removed from the graph, graph becomes directed acyclic graph.AlgorithmBegin function checkCG(int n) : n: number of vertices. arr: struct graph variable. Initialize cnt = 0 and size = (n-1). For i = 0 to n-1 if (cnt == size) return 0 if (arr[i].ptr == NULL) Increase cnt. for j = 0 to n-1 while (arr[j].ptr ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
188 Views
A graph is a tree if it does not contain any cycle. This is a C++ program to check whether a directed graph is tree or not using DFS.AlgorithmBegin function cyclicUtil() : a) Mark the current node as visited and part of recursion stack b) Recur for all the vertices adjacent to this vertex. c) Remove the vertex from recursion stack. function cyclic() : a) Mark all the vertices as not visited and not part of recursion stack b) Call the CyclicUtill() function to detect cycle in different trees EndExample#include #include #include using ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
163 Views
A graph is a tree if it does not contain any cycle. This is a C++ program to check whether an undirected graph is tree or not.AlgorithmBegin function cyclicUtil() : A) Mark the current node as visited. B) Recur for all the vertices adjacent to this vertex. C) If an adjacent is not visited, then recur for that adjacent. D) If an adjacent is visited and not parent of current vertex, then there is a cycle. End Begin function cyclic(): A) Mark all the vertices as not visited and not part of recursion stack. ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
7K+ Views
In this section we will see how to see the Host name and IP address of the local system in an easier way. We will write a C program to find the host name and IP.Some of the following functions are used. These functions have different task. Let us see the functions and their tasks.Sr.NoFunction & Description1gethostname()It finds the standard host name for the local computer.2gethostbyname()It finds the host information corresponding to a host name from host database3iten_ntoa()It converts an IPv4 Internet network address into an ASCII string into dotted decimal format.Example#include #include #include #include #include ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
287 Views
In C++ the structure and class are basically same. But there are some minor differences. These differences are like below.The class members are private by default, but members of structures are public. Let us see these two codes to see the differences.Example#include using namespace std; class my_class { int x = 10; }; int main() { my_class my_ob; cout
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
32K+ Views
Sometimes we use int main(), or sometimes void main(). Now the question comes into our mind, that what are the differences between these two.The main() function is like other functions. It also takes arguments, and returns some value. One point we have to keep in mind that the program starts executing from this main() function. So the operating system calls this function. When some value is returned from main(), it is returned to operating system.The void main() indicates that the main() function will not return any value, but the int main() indicates that the main() can return integer type data. ... Read More