C++ Program to Perform Sorting Using B-Tree

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

336 Views

Here we will see how to get the sorted sequence using B-Tree. The B-tree is n-ary tree. To get the sorted sequences, we can create a B-tree, then add the numbers into it. Here the B-tree can hold maximum 5 nodes. If number of nodes increases, split the node and form new level. As the nodes are holding few number of elements like 5 (at most), we are using Bubble sorting techniques to sort them. as the number of elements is very low, then it will not affect too much on its performance.After traversing the tree, we will get all ... Read More

How to set the alignment of the JLabel content along the Y axis in Java?

Smita Kapse
Updated on 30-Jul-2019 22:30:26

345 Views

To set the alignment of the label content along the Y axis, use the setVerticalAlignment() method. Let us first set a label component. We have set the label background color as well so that we can check the alignment of the label’s content properly −JLabel label = new JLabel("Product Name "); label.setPreferredSize(new Dimension(190, 100)); label.setOpaque(true); label.setBackground(Color.ORANGE);Now, we will align the label content along the Y axis −label.setVerticalAlignment(JLabel.CENTER);The following is an example to set the alignment of the JLabel content along the Y axis −Examplepackage my; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextArea; import javax.swing.WindowConstants; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame("Our Frame ... Read More

How to get tag count in MongoDB query results based on list of names?

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

100 Views

You can use $in operator. Let us first create a collection with documents −> db.tagCountDemo.insertOne({"ListOfNames":["John", "Sam", "Carol"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd64b387924bb85b3f48944") } > db.tagCountDemo.insertOne({"ListOfNames":["Bob", "David", "John"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd64b4b7924bb85b3f48945") } > db.tagCountDemo.insertOne({"ListOfNames":["Mike", "Robert", "Chris"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd64b5d7924bb85b3f48946") } > db.tagCountDemo.insertOne({"ListOfNames":["James", "Carol", "Jace"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd64b717924bb85b3f48947") }Following is the query to display all documents from a collection with the help of find() method −> db.tagCountDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cd64b387924bb85b3f48944"),    "ListOfNames" : ... Read More

isnormal() in C++

Smita Kapse
Updated on 30-Jul-2019 22:30:26

69 Views

In this section we will see the isnormal() function in C++. This function is present in the cmath library. This function is used to check whether a number is normal or not. The numbers that are considered as non-normal are zeros, infinity or NAN.This function takes float, double or long double values as argument. Returns 1 if the number is normal, otherwise returns 0.Example Live Demo#include #include using namespace std; int main() {    cout

Can we create an enum with custom values in java?

Venkata Sai
Updated on 30-Jul-2019 22:30:26

7K+ Views

Enumeration (enum) in Java is a datatype which stores a set of constant values (Strings in general). You can use enumerations to store fixed values such as days in a week, months in a year etc.enum Days { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }Custom values to the constantsInstead of declaring just string constants in an enum, you can also have values to these constants as −enum Vehicles { ACTIVA125(80000), ACTIVA5G(70000), ACCESS125(75000), VESPA(90000), TVSJUPITER(75000); }Whenever, you need to assign custom values to the constants of an enum −To hold the value of each ... Read More

HTML DOM Input FileUpload name Property

Sharon Christine
Updated on 30-Jul-2019 22:30:26

50 Views

The HTML DOM FileUpload name property returns and modify the value of the name attribute of an fileupload input type in HTML.SyntaxFollowing is the syntax −1. Returning nameobject.name2. Setting nameobject.name=”text”ExampleLet us see an example of FileUpload name property − Live Demo HTML DOM name Property    body{       background-color:#397367;       color:#fff;       padding:20px;    }    .btn{       display:block;       background-color:#22223B;       color:#fff;       border:none;       padding:0.5rem;       border-radius:50px;       width:80%;       margin:10px;    }   ... Read More

HTML DOM Input Email placeholder Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

77 Views

The HTML DOM Input Email placeholder property sets/returns a string generally used to give hints to user of what the input text will look like.SyntaxFollowing is the syntax −Returning string valueinputEmailObject.placeholderSetting placeholder to stringValueinputEmailObject.placeholder = stringValueExampleLet us see an example of Input Email placeholder property − Input Email placeholder    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } ... Read More

Print an array with numbers having 1, 2 and 3 as a digit in ascending order

Sunidhi Bansal
Updated on 30-Jul-2019 22:30:26

529 Views

Here, the task is to print those number in an array having 1, 2 and 3 as digits in their numbers and if their is no such number than the output must be -1Input : arr[] = {320, 123, 124, 125, 14532, 126, 340, 123400, 100032, 13, 32, 3123, 1100} Output : 123 3123 14532 100032 123400 Since the array have values with digits 1, 2 and 3 it wouldn’t return -1 and print 5 values that Contain 1, 2 and 3 in their respective numbers.AlgorithmSTART Step 1 -> Declare array with elements of int type as arr Step ... Read More

MongoDB query to match each element in a documents array to a condition?

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

148 Views

You can use every() in MongoDB for this. Let us create a collection with documents −> db.arrayConditionDemo.insertOne({"Name":"John", "Marks":[40, 43, 45]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cbdbd06de8cc557214c0e1a") } > db.arrayConditionDemo.insertOne({"Name":"Mike", "Marks":[45]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cbdbd17de8cc557214c0e1b") } > db.arrayConditionDemo.insertOne({"Name":"Chris", "Marks":[43, 45, 59, 69, 78, 89]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cbdbd3cde8cc557214c0e1c") }Display all documents from a collection with the help of find() method. The query is as follows −> db.arrayConditionDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cbdbd06de8cc557214c0e1a"),    "Name" : "John",    "Marks" : [       ... Read More

C++ Program to Check Whether Topological Sorting can be Performed in a Graph

Anvi Jain
Updated on 30-Jul-2019 22:30:26

428 Views

In a Directed Acyclic Graph, we can sort vertices in linear order using topological sort.Topological sort is only work on Directed Acyclic Graph. In a Directed Acyclic Graph (DAG), there can be more than one topological sort.In the following C++ program, we shall perform topological sort to check existence of a cycle in a graph.AlgorithmsFor function Topo_SortBegin    Define function Topo_Sort()       Declare x to the integer datatype, vstd[] of the Boolean array and Stack as a stack.          Pass them as parameter.       Initialize vstd[x] = true to mark the current node ... Read More

Advertisements