Nishtha Thakur has Published 564 Articles

List all values of a certain field in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

1K+ Views

To get the list of all values of certain fields in MongoDB, you can use distinct(). The syntax is as follows −db.yourCollectionName.distinct( "yourFieldName");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.listAllValuesOfCeratinFieldsDemo.insertOne({"ListOfValues":[10, 20, ... Read More

Getting the highest value of a column in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

845 Views

To get the highest value of a column in MongoDB, you can use sort() along with limit(1). The syntax is as follows −db.yourCollectionName.find().sort({"yourFieldName":-1}).limit(1);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.gettingHighestValueDemo.insertOne({"Value":1029}); { ... Read More

C++ Program to Implement B Tree

Nishtha Thakur

Nishtha Thakur

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

5K+ Views

The B-tree is a generalization of a binary search tree in that a node can have more than two children. It is basically a self-balancing tree data structure that maintains sorted data and allows sequential access, searches, insertions, and deletions in logarithmic time.Here is a C++ program to implement B ... Read More

C++ Program to Find Hamiltonian Cycle in an UnWeighted Graph

Nishtha Thakur

Nishtha Thakur

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

2K+ Views

A Hamiltonian cycle is a Hamiltonian Path such that there is an edge (in graph) from the last vertex to the first vertex of the Hamiltonian Path. It is in an undirected graph is a path that visits each vertex of the graph exactly once.Functions and purposesBegin    1. function ... Read More

LongStream peek() method in Java

Nishtha Thakur

Nishtha Thakur

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

114 Views

The peek() method of the LongStream class returns a stream with the elements of this stream, additionally performing the provided action on each element as elements are consumed from the resulting stream.The syntax is as follows −LongStream peek(LongConsumer action)Here, LongConsumer represents an operation that accepts a single long-valued argument and ... Read More

C++ Program to Implement Cartesian Tree

Nishtha Thakur

Nishtha Thakur

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

289 Views

Here is a C++ Program to Implement Cartesian Tree.AlgorithmBegin    class CarTree to declare the functions:       min() = To find index of the minimum element in array:    if (arr[i] < min)       min = arr[i]       minind = i       ... Read More

How to list all collections from a particular MongoDB database?

Nishtha Thakur

Nishtha Thakur

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

178 Views

If you want to list all collections from a particular database then you need to switch the database first. The query is as follows −> use sample; switched to db sample > db.getCollectionNames();The following is the output −[    "copyThisCollectionToSampleDatabaseDemo",    "deleteDocuments",    "deleteDocumentsDemo",    "deleteInformation",    "employee",    "internalArraySizeDemo", ... Read More

Collectors toList() method in Java 8

Nishtha Thakur

Nishtha Thakur

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

2K+ Views

The toList() method of the Collectors class returns a Collector that accumulates the input elements into a new List.The syntax is as follows −static Collector toList()Here, parameter T is the type of input elements.To work with Collectors class in Java, import the following package −import java.util.stream.Collectors;The following is an ... Read More

C++ Program to Find the Maximum Cut in a Graph

Nishtha Thakur

Nishtha Thakur

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

438 Views

In this program to find the maximum Cut in a graph, 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 ... Read More

How to use substr () in Android sqlite?

Nishtha Thakur

Nishtha Thakur

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

217 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to ... Read More

Advertisements