A BST or binary search tree is a form of binary tree that has all left nodes smaller and all right nodes greater than the root value. For this problem, we will take a binary tree and add all the values greater than the current node to it. the problem “ add all greater values to every node in BST” is simplified as for a BST add all the node values that are greater than the current node value to that node value.Add all greater values to each node in the BST Problem Statement:Given a Binary Search Tree (BST), we ... Read More
Here we will see how the brick sort works. The Brick sort is one modification of bubble sort. This algorithm is divided into two parts. These parts are odd part and even parts. In the odd part we will use the bubble sort on odd indexed items, and in the even part we will use the bubble sort on even indexed elements. Let us see the algorithm to get the idea.AlgorithmbrickSort(arr, n)begin flag := false while the flag is not true, do flag := true for i := 1 to n-2, increase ... Read More
The HTML DOM Input Time stepUp() method defines the number of minutes the Time field should increase.SyntaxFollowing is the syntax −Calling stepUp() method with a number, which by default is equal to 1inputTimeObject.stepUp(number)ExampleLet us see an example of Input Time stepUp method − Live Demo Input Time stepUp() form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } Time-stepUp( ) ... Read More
Selenium is an open source framework used for automation of web applications. Apart from this, it can also work on various administrative tasks such as monitoring of websites.There are 4 flavors of Selenium −Selenium-IDE.Selenium-RC.Selenium Grid.Selenium Web Driver.Let’s have a look at the uses of each of them −Selenium IDE − It is the Integrated Development Environment which has easy to use interface used for building and running Selenium Test Cases. It is a prototyping tool for building test scripts in a way that it records the user actions as they are performed. The recorded actions are stored as a script ... Read More
Selenium RC or Remote Control is the initial version of Selenium which is also referred to as Selenium1. RC uses a JavaScript Program called Selenium core which controls the browser. It works by intimating the user action as commanded by the JavaScript commands but that does not enforce user to write automated test cases in the only JavaScript, let’s see how does RC make that happen.The above diagram depicts the brief architecture of the Selenium RC.Selenium RC contains the following components −Selenium Server − It acts as the central processor for your entire application. It receives the script for the ... Read More
A CSV stands for Comma Separated Values. In a CSV file, each line contains words that are separated with a comma(, ) and it is stored with a .csv extension.We can read a CSV file line by line using the readLine() method of BufferedReader class. Split each line on comma character to get the words of the line into an array. Now we can easily print the contents of the array by iterating over it or by using an appropriate index.CSV FileExampleimport java.io.*; public class CSVReaderTest { public static final String delimiter = ", "; public static void read(String csvFile) { ... Read More
There are n number of elements stored in an array and this program calculates the average of those numbers. Using different methods.Input - 1 2 3 4 5 6 7Output - 4Explanation - Sum of elements of array 1+2+3+4+5+6+7=28No of element in array=7Average=28/7=4There are two methodsMethod 1 −IterativeIn this method we will find sum and divide the sum by the total number of elements.Given array arr[] and size of array nInput - 1 2 3 4 5 6 7Output - 4Explanation - Sum of elements of array 1+2+3+4+5+6+7=28No of element in array=7Average=28/7=4Example#include using namespace std; int main() { int arr[] = { 1, 2, 3, ... Read More
This example demonstrates how do I register a BroadcastReceiver programtically in android.Step 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. Step 3 − Add the following code to src/MainActivity.javaimport android.content.IntentFilter; import android.net.ConnectivityManager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { ExampleBroadcastReceiver exampleBroadcastReceiver = new ExampleBroadcastReceiver(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } protected void onStart(){ ... Read More
This example demonstrates how do I use snackBar in android.Step 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. Step 3 – Open build.gradle(Module app) add the following dependancy -implementation 'com.android.support:design:28.0.0'Step 4 − Add the following code to src/MainActivity.javaimport android.graphics.Color; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ... Read More
The string is actually a one-dimensional array of characters which is terminated by a null character '\0'. Thus a null-terminated string contains the characters that comprise the string followed by a null.To find the length of a string we need to loop and count all words in the loop until the ‘\0’ character is matched.For exampleInput −naman Output − string length is 5Explanation − we need to iterate over each index of the string until reach the end of string means ‘\0’ which is the null character. Example#include #include int main() { char string1[]={"naman"}; int i=0, length; while(string1[i] !='\0') ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP