Given with inorder and preorder of a tree program must find the postroder traversal and print the sameInput: Inorder traversal in[] = {4, 2, 5, 1, 3, 6} Preorder traversal pre[] = {1, 2, 4, 5, 3, 6} Output: Postorder traversal post[] = {4, 5, 2, 6, 3, 1}AlgorithmSTART Step 1 -> declare function as find_value(int p, int in_order[], int n) Loop For i=0 and i declare function as postorder(int pre_order[], int in_order[], int n) Declare int variable as root = find_value(pre_order[0], in_order, n) IF root!=0 Call postorder(pre_order+1, in_order, root) End IF ... Read More
You need to switch the database to admin. Following is the syntax −use adminThe syntax is as follows for shutdown option −db.shutdownServer()Let us implement the above syntax for shutdown −> use admin switched to db admin > db.shutdownServer()This will produce the following output −server should be down... 2019-04-22T19:11:40.949+0530 I NETWORK [js] trying reconnect to 127.0.0.1:27017 failed 2019-04-22T19:11:42.197+0530 I NETWORK [js] reconnect 127.0.0.1:27017 failed failed
The getColumnType() method of the ResultSetMetaData (interface) retrieves the type of the specified column in the current ResultSet object.This method accepts an integer value representing the index of a column and, returns an integer value representing the SQL type of the specified column.Following is the list of values returned by various datatypes of java.sql.Type −Array: 2003Big int: -5Binary: -2Bit: -7Blob: 2004Boolean: 16Char: 1Clob: 2005Date: 91Datalink70Decimal: 3Distinct: 2001Double: 8Float: 6Integer: 4JavaObject: 2000Long var char: -16Nchar: -15NClob: 2011Varchar: 12VarBinary: -3Tiny int: -6Time stamt with time zone: 2014Timestamp: 93Time: 92Struct: 2002SqlXml: 2009Smallint: 5Rowid: -8Refcursor: 2012Ref: 2006Real: 7Nvarchar: -9Numeric: 2Null: 0Smallint: 5To get the ResultSetMetaData ... Read More
You need to use changeUserPassword() to change a user’s password. Let us first create a user with some roles. Following is the query to create a user in MongoDB −> use admin switched to db admin > db.createUser( ... { ... user: "Chris", ... pwd: "chris", ... roles: [ { role: "readWrite", db: "test" } ] ... } ... ); Successfully added user: { "user" : "Chris", "roles" : [ { "role" : "readWrite", "db" : ... Read More
Detached Dom elementsDetached DOM elements are the elements which have been removed from the DOM but their memory is still retained because of JavaScript. This means that as long the element have a reference to any variable or an object anywhere, it does not garbage collected even after destroyed from the DOM.DOM is like an double-linked tree which means a reference to a node in the tree will halt the entire tree from garbage collection.Let's take an example of creating a DOM element in javascript. After creating the element destroy it but forget to delete the variable holding it. This ... Read More
To push elements to an existing array, use $addToSet operator along with update(). Let us first create a collection with documents −> db.pushElements.insertOne({"Comments":["Good", "Awesome", "Nice"]}); { "acknowledged" : true, "insertedId" : ObjectId("5cd682597924bb85b3f48953") }Following is the query to display all documents from a collection with the help of find() method −> db.pushElements.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cd682597924bb85b3f48953"), "Comments" : [ "Good", "Awesome", "Nice" ] }Following is the query to push elements to an existing array in MongoDB −> db.pushElements.update( {_id:ObjectId("5cd682597924bb85b3f48953")}, { ... Read More
Here we will see the Shuffle and random_shuffle in C++. Let us see the random_shuffle first. It is used to randomly rearrange the elements in range [left, right). This function randomly swaps the positions of each element with the position of some randomly chosen positions.We can provide some random generator function to tell which element will be taken in every case. If we do not provide some, it will use its own random generator function.Example Live Demo#include using namespace std; int myRandomGenerator(int j) { return rand() % j; } main() { srand(unsigned(time(0))); vector arr; for (int ... Read More
The HTML DOM input FileUpload Object represents the
In this problem, we have to find some binary numbers which have no consecutive 1s. In a 3-bit binary string, there are three binary numbers 011, 110, 111, who have consecutive 1s, and five numbers are there which have no consecutive 1s. So after applying this algorithm for 3-bit numbers, the answer will be 5.If a[i] be the set of binary numbers, whose number of bits are i, and not containing any consecutive 1s, and b[i] is the set of binary number, where number of bits are i, and containing consecutive 1s, then there are recurrence relations like −a[i] := ... Read More
Given with a linked list program must print the list starting from the end till the front using the stack data structureInput : 10 -> 5 -> 3 -> 1 -> 7 -> 9 Output: 9 -> 7 -> 1 -> 3 -> 5 -> 10Here the user can use the approach of poping elements from the stack pointing top at the stack[0] location and than going till stack[n] elementAlgorithmSTART Step 1 -> create structure Linked_list Declare int data Declare struct linked_list *next End Step 2 -> declare int stack[30], top = -1 Step 3 -> declare struct ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP