Smita Kapse has Published 560 Articles

Decision Making in C++

Smita Kapse

Smita Kapse

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

164 Views

Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to ... Read More

Delete all elements in an array field in MongoDB?

Smita Kapse

Smita Kapse

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

1K+ Views

You can use $set operator for this. The syntax is as follows −db.yourCollectionName.update({}, { $set : {"yourFieldName": [] }} , {multi:true} );To understand the above syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.deleteAllElementsInArrayDemo.insertOne({"InstructorName":"Larry", "InstructorTechnicalSubject":["Java", "MongoDB"]}); ... Read More

How to perform ascending order sort in MongoDB?

Smita Kapse

Smita Kapse

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

172 Views

To sort in ascending order, the syntax is as follows −db.yourCollectionName.find().sort({yourField:1});To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.sortingDemo.insertOne({"Value":100}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8f8e2ed3c9d04998abf006") } > db.sortingDemo.insertOne({"Value":1}); {   ... Read More

In MongoDB how do you use $set to update a nested value/embedded document?

Smita Kapse

Smita Kapse

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

1K+ Views

The syntax is as follows for this −db.yourCollectionName.update({ }, { $set: { "yourOuterFieldName.yourInnerFieldName": "yourValue" } });To understand the syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.updateNestedValueDemo.insertOne({"CustomerName":"Chris",    ... "CustomerDetails":{"CustomerAge":25, "CustomerCompanyName":"Google", "CustomerCityName":"US"}}); {    "acknowledged" : ... Read More

Collectors averagingDouble() method in Java 8

Smita Kapse

Smita Kapse

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

332 Views

The averagingDouble() method of the Collectors class in Java 8 returns a Collector that is the arithmetic mean of a double-valued function applied to the input elements.The syntax is as follows −public static Collector averagingDouble(ToDoubleFunction

C++ Program to Find a Good Feedback Edge Set in a Graph

Smita Kapse

Smita Kapse

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

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

How to use hash set in Android?

Smita Kapse

Smita Kapse

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

291 Views

This example demonstrate How to use hash set in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.             ... Read More

StringJoiner add() method in Java 8

Smita Kapse

Smita Kapse

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

142 Views

The add() method of the StringJoiner class is used in Java 8 to add a copy of the given CharSequence value as the next element of the StringJoiner value. If the new element ele is null, then the value null gets added.The syntax is as follows −public StringJoiner add(CharSequence ele)Here, ... Read More

How to copy a collection from one database to another in MongoDB?

Smita Kapse

Smita Kapse

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

2K+ Views

In MongoDB, the command does not exist to copy a collection from one database to another. To achieve it, use the below concept −db.yourCollectionName.find().forEach(function(yourVariableName){    db.getSiblingDB('yourDestinationDatabase')['yourCollectionName'].insert(yourVariableName); });Let us create a collection in the test database and copy this collection to another database with the name „sample‟.To understand the above syntax, ... Read More

C++ Program to Find the Connected Components of an UnDirected Graph

Smita Kapse

Smita Kapse

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

716 Views

Weakly or Strongly Connected for a given a undirected graph can be found 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 all ... Read More

Advertisements