Arjun Thakur has Published 1025 Articles

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

Arjun Thakur

Arjun Thakur

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

271 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

721 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

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

264 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

114 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

286 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

C++ Program to Find SSSP (Single Source Shortest Path) in DAG (Directed Acyclic Graphs)

Arjun Thakur

Arjun Thakur

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

2K+ Views

This is a C++ program to find SSSP (Single Source Shortest Path) in DAG (Directed Acyclic Graphs) using Dijkstra Algorithm to find out from the first node in graph to every other node with the shortest path length showed beside each pair of vertices.AlgorithmBegin    Take the elements of the ... Read More

Search multiple fields for multiple values in MongoDB?

Arjun Thakur

Arjun Thakur

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

713 Views

To search multiple fields for multiple values in MongoDB, you can use $text and $search operator. Let us first create a collection with documents>db.searchMultipleFieldsDemo.insertOne({"_id":100, "FirstSubject":"Java", "SecondSubject":"MongoDB"}); { "acknowledged" : true, "insertedId" : 100 } >db.searchMultipleFieldsDemo.insertOne({"_id":101, "FirstSubject":"MongoDB", "SecondSubject":"MySQL"}); { "acknowledged" : true, "insertedId" : 101 } >db.searchMultipleFieldsDemo.insertOne({"_id":102, "FirstSubject":"MySQL", "SecondSubject":"Java"}); { "acknowledged" ... Read More

C++ Program to Find the Edge Connectivity of a Graph

Arjun Thakur

Arjun Thakur

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

539 Views

In this program we need to find the Edge Connectivity of a Graph. An Edge Connectivity of a Graph of a graph means it is a bridge, removing it graph will be disconnected. Number of connected components increases with the removing of bridge in a disconnected undirected graph.Functions and pseudocode:Begin ... Read More

Split a string and insert it as individual values into a MySQL table?

Arjun Thakur

Arjun Thakur

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

840 Views

You can achieve this with the help of prepared statement in MySQL. First you need to create a table. The query to create a table is as followsmysql> create table University - > ( - > UserId int, - > UniversityId ... Read More

Advertisements