C++ Program to Find Transpose of a Graph Matrix

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

360 Views

In this program we take a matrix and prints the transpose of the matrix. In a transpose matrix, rows become columns and vice versa.AlgorithmBegin Take number of rows and columns of the matrix. Take The elements of the matrix and stored in the matrix ‘A’. The transpose matrix is found by exchanging the rows with columns and columns with rows. Print both the original matrix and the transpose. End.Example Code#include using namespace std; int main () {    int A[10][10], a, b, i, j;    cout > a>> b;    cout > A[i][j];       cout

Case-Insensitive Query in MongoDB

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

390 Views

Yes, you can use regexp to make a case-insensitive query in MongoDB. The syntax is as follows:db.yourCollectionName.find({"yourFieldName":/^yourvalue$/i});To understand the above syntax, let us create a collection with some documents. The query to create a collection with documents is as follows:> db.caseInsensitiveDemo.insertOne({"Name":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6d7a67f2db199c1278e7ef") } > db.caseInsensitiveDemo.insertOne({"Name":"JOHN"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6d7ad6f2db199c1278e7f0") }Display all documents from a collection with the help of find(). The query is as follows:> db.caseInsensitiveDemo.find();The following is the output:{ "_id" : ObjectId("5c6d7a67f2db199c1278e7ef"), "Name" : "John" } { "_id" : ObjectId("5c6d7ad6f2db199c1278e7f0"), "Name" : "JOHN" }Here is the ... Read More

Write a While Loop in a JSP Page

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

2K+ Views

Following is the while loop example −           WHILE LOOP Example                           JSP Tutorial                           The above code will generate the following result −JSP Tutorial JSP Tutorial JSP Tutorial

DoubleStream of Method in Java

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

243 Views

The DoubleStream class in Java the following two forms of the of() methodThe following of() method returns a sequential DoubleStream containing a single element. Here is the syntaxstatic DoubleStream of(double t)Here, parameter t is the single element.The following of() method returns a sequential ordered stream whose elements are the specified valuesstatic DoubleStream of(double… values)Here, the parameter values are the elements of the new stream.To use the DoubleStream class in Java, import the following packageimport java.util.stream.DoubleStream;The following is an example to implement DoubleStream of() method in JavaExample Live Demoimport java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) ... Read More

Get Month from LocalDate in Java

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

4K+ Views

The month name for a particular LocalDate can be obtained using the getMonth() method in the LocalDate class in Java. This method requires no parameters and it returns the month name in the year.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalDate ld = LocalDate.parse("2019-02-14");       System.out.println("The LocalDate is: " + ld);       System.out.println("The month is: " + ld.getMonth());    } }OutputThe LocalDate is: 2019-02-14 The month is: FEBRUARYNow let us understand the above program.First the LocalDate is displayed. ... Read More

Difference Between Private, Public, and Protected Inheritance in C++

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

3K+ Views

Data hiding is one of the important features of Object Oriented Programming which allows preventing the functions of a program to access directly the internal representation of a class type. The access restriction to the class members is specified by the labeled access modifiers: public, private, and protected sections within the class body.The default access for members and classes is private.Example Codeclass Base { public:     // public members go here protected: // protected members go here private:     ... Read More

Count Number of Keys in a MongoDB Document

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

527 Views

There is no in-built function to count a number of keys in a document. In order to count a number of keys, you need to write some code.Let us create a collection with a document. The query to create a collection with a document is as follows −> db.numberofKeysInADocumentDemo.insertOne({    "UserName":"John", "UserAge":21, "UserEmailId":"john12@gmail.com", "UserCountryName":"US"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9132584afe5c1d2279d6ac") }Display all documents from a collection with the help of find() method. The query is as follows −> db.numberofKeysInADocumentDemo.find().pretty();The following is the output −{    "_id" : ObjectId("5c9132584afe5c1d2279d6ac"),    "UserName" : "John",    "UserAge" : 21,   ... Read More

Understanding Logistic Regression in Python

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

395 Views

Logistic Regression is a statistical technique to predict the binary outcome. It’s not a new thing as it is currently being applied in areas ranging from finance to medicine to criminology and other social sciences.In this section we are going to develop logistic regression using python, though you can implement same using other languages like R.InstallationWe’re going to use below libraries in our example program, Numpy: To define the numerical array and matrixPandas: To handle and operate on dataStatsmodels: To handle parameter estimation & statistical testingPylab: To generate plotsYou can install above libraries using pip by running below command in ... Read More

Check If MongoDB Database Exists

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

3K+ Views

There are two possibilities to check if MongoDB database exists.Case 1: The first possibility is that the MongoDB database exists i.e. it returns particular index.Case 2: The second possibility is that the MongoDB database does not exist i.e. it returns index -1.NOTE: An index starts from 0 and ends with (N-1) like an array.The syntax is as follows to check if MongoDB database exists.db.getMongo().getDBNames().indexOf("yourDatabaseName");Case 1: Let us implement the above syntax to check if MongoDB database exists. Following is the querydb.getMongo().getDBNames().indexOf("test");This will produce the following output6Look at the above sample output, we are getting 6 that means the database “test” ... Read More

Extract Multiple Integers from a String in Java

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

861 Views

Let’s say the following is our string with integer and characters −String str = "(29, 12; 29, ) (45, 67; 78, 80)";Now, to extract integers, we will be using the following pattern −\dWe have set it with Pattern class −Matcher matcher = Pattern.compile("\d+").matcher(str);Example Live Demoimport java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Demo {    public static void main(String[] args) {       String str = "(29, 12; 29, ) (45, 67; 78, 80)";       Matcher matcher = Pattern.compile("\d+").matcher(str);       Listlist = new ArrayList();       while(matcher.find()) {          list.add(Integer.parseInt(matcher.group()));       }       System.out.println("Integers = "+list);    } }OutputIntegers = [29, 12, 29, 45, 67, 78, 80]

Advertisements