To select one specific row and another random row, you can use ORDER BY and RAND(). Let us first create a sample table:mysql> create table oneSpecificRowAndOtherRandom -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.72 sec)Following is the query to insert some records in the table using insert command:mysql> insert into oneSpecificRowAndOtherRandom(Name) values('Larry'); Query OK, 1 row affected (0.56 sec) mysql> insert into oneSpecificRowAndOtherRandom(Name) values('Sam'); Query OK, 1 row affected (0.13 sec) mysql> insert into oneSpecificRowAndOtherRandom(Name) values('Mike'); Query OK, 1 row affected ... Read More
A graph is a tree if it does not contain any cycle. This is a C++ program to check whether a directed graph is tree or not using DFS.AlgorithmBegin function cyclicUtil() : a) Mark the current node as visited and part of recursion stack b) Recur for all the vertices adjacent to this vertex. c) Remove the vertex from recursion stack. function cyclic() : a) Mark all the vertices as not visited and not part of recursion stack b) Call the CyclicUtill() function to detect cycle in different trees EndExample#include #include #include using ... Read More
This is a C++ program to implement Modular Exponentiation Algorithm.AlgorithmBegin function modular(): // Arguments: base, exp, mod. // Body of the function: initialize res = 1 while (exp > 0) if (exp mod 2 == 1) res= (res * base) % mod exp = exp left shift 1 base = (base * base) % mod return res. EndExample#include using namespace std; long long modular(long long base, long long exp, int mod) { long long res = 1; while (exp > 0) { if (exp % 2 == 1) res= (res * base) % mod; exp = exp >> 1; base = (base * base) % mod; } return res; } int main() { long long b, e; int mod; coutb; coute; coutmod; cout
The first day of employment for any employee: be a fresher, experienced person, or managerial, will always start off with a training session. The day-long training completes with numerous amount of information, but does so much effort made by the Organization is worth the money invested in the training sessions. We all agree that training is the key to a well-motivated, knowledgeable, and efficient staff.Here we are going to discuss the top reasons on why the training sessions do not help your employees, and why this whole expenditure on training is not fruitful. We will check out the conditions because of ... Read More
Kindle is great to reduce eye tension. Kindle is absolutely easy on your sight and is very comfortable to read on. As well, the display on the latest Kindle is built to prevent glare, even in sunlight. In addition to that:Perfect Travel-Around PartnerThe Kindle is so small, light and portable that it is straightforward to carry around anywhere you go and also you don't have to worry about the edges of your publication folding anymore. It also helps that your total library suits this tiny device, so you're indulged for choice while on vacation.Read At NighttimeIf you want to learn ... Read More
Before getting into an example, we should know what thread in android is. Threads are generic processing tasks that can do most things, but one thing they cannot do is update the UI.This example demonstrates about How to run continues thread 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. In the above code, we have taken textview. When the user clicks on textview, it will start continues thread ... Read More
The with() method is used to create Septet Tuple in Java.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following package −import org.javatuples.Septet;Note − Steps to download and run JavaTuples program If you are using Eclipse IDE to run Septet Class in JavaTuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Septet; public class Demo { public static void main(String[] args) { Septet < ... Read More
This driver is known as a native API driver. This driver receives the calls from Java application and converts them in to vender specific native API calls. Here, we need to install The vendor-specific driver on the client machines.If we change the Database, we have to change the native API, as it is specific to a database and they are mostly obsolete now, but you may realize some speed increase with a Type 2 driver because it eliminates ODBC's overhead.Advantages of type2 driverFollowing are the advantages of the type2 driver.This type of driver fastest among all the 4 types of ... Read More
To read cookies, you need to create an array of javax.servlet.http.Cookie objects by calling the getCookies( ) method of HttpServletRequest. Then cycle through the array, and use getName() and getValue() methods to access each cookie and associated value.Let us now read cookies that were set in the previous example −Example Live Demo Reading Cookies Reading Cookies Let us now put the above code in main.jsp file and try to access it. If you set ... Read More
This example demonstrate about How to use replaceAll () in Android textview.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. In the above code, we have taken name as Edit text, when user click on button it will take data and replace space with emptystring.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; ... Read More