Arjun Thakur has Published 1109 Articles

C++ Program to Check whether Graph is a Bipartite using DFS

Arjun Thakur

Arjun Thakur

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

183 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 ... Read More

Filter the records of current day, month and year in MySQL?

Arjun Thakur

Arjun Thakur

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

485 Views

Let’s say you have a table with UserLoginTime column wherein we have stored some values for sample. This is the login time of users and we want to filter all these records on the basis of current day, month and year i.e. the current date. We will beLet us now ... Read More

Passing by pointer Vs Passing by Reference in C++

Arjun Thakur

Arjun Thakur

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

3K+ Views

These are simple example of passing by pointer and passing by reference -Passing by pointer Live Demo#include using namespace std; void swap(int* a, int* b) {    int c = *a;    *a= *b;    *b = c; } int main() {    int m = 7, n = 6;    cout

C++ Program to Apply DFS to Perform the Topological Sorting of a Directed Acyclic Graph

Arjun Thakur

Arjun Thakur

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

1K+ Views

Topological sorting of DAG (Directed Acyclic Graph) is a linear ordering of vertices such that for every directed edge uv, where vertex u comes before v in the ordering. If the graph is not a DAG, Topological Sorting for a graph is not possible.Functions and pseudocodesBegin    function topologicalSort():   ... Read More

Generate Infinite Stream of Integers in Java using Random.ints()

Arjun Thakur

Arjun Thakur

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

166 Views

To generate Infinite Stream of Integers, you can use the Random class and its ints() methodRandom.ints()Here, we have used the ints() method to get the next integer.The following is an example displaying how to generate Infinite Stream of Integers with Random.ints() in JavaExampleimport java.util.stream.*; import java.util.*; public class Demo { ... Read More

Get all the MongoDB documents but not the ones with two given criteria’s?

Arjun Thakur

Arjun Thakur

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

68 Views

To get all the MongoDB documents with some given criteria’s, following any of the below given casesCase 1 Following is the query to get all the documents without a single criterion using $ne operatordb.yourCollectionName.find({yourFieldName:{$ne:"yourValue"}}).pretty();Case 2 Following is the query to get all the documents without two given criterions using $nin ... Read More

C++ Program to Check Whether it is Weakly Connected or Strongly Connected for a Directed Graph

Arjun Thakur

Arjun Thakur

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

194 Views

Weakly or Strongly Connected for a given a directed graph can be find out using DFS. This is a C++ program of this problem.Functions usedBegin    Function fillorder() = fill stack with all the vertices.    a) Mark the current node as visited and print it    b) Recur for ... Read More

Pointers vs References in C++

Arjun Thakur

Arjun Thakur

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

9K+ Views

PointersPointers are used to store the address of variable.SyntaxType *pointer;InitializationType *pointer; pointer = variable name;ReferencesWhen a variable is declared as reference, it becomes an alternative name for an existing variable.SyntaxType &newname = existing name;InitializationType &pointer; pointer = variable name;The main differences between pointers and references are -References are used to ... Read More

C++ Program to Find Number of Articulation points in a Graph

Arjun Thakur

Arjun Thakur

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

413 Views

Articulation Points (or Cut Vertices) in a Graph is a point iff removing it (and edges through it) disconnects the graph. An articulation point for a disconnected undirected graph, is a vertex removing which increases number of connected components.AlgorithmBegin    We use dfs here to find articulation point:    In ... Read More

C++ Program to Find Path Between Two Nodes in a Graph

Arjun Thakur

Arjun Thakur

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

657 Views

In this Program we can find out whether path exists between two nodes by using DFS on given graph.AlgorithmBegin    function isReach() is a recursive function to check whether d is reachable to s :    A) Mark all the vertices as unvisited.    B) Mark the current node as ... Read More

Advertisements