Construct Transitive Closure Using Warshall's Algorithm in C++

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

905 Views

If a directed graph is given, determine if a vertex j is reachable from another vertex i for all vertex pairs (i, j) in the given graph. Reachable mean that there is a path from vertex i to j. This reach-ability matrix is called transitive closure of a graph. Warshall algorithm is commonly used to find the Transitive Closure of a given graph G. Here is a C++ program to implement this algorithm.AlgorithmBegin    1.Take maximum number of nodes as input.    2.For Label the nodes as a, b, c …..    3.To check if there any edge present between ... Read More

Use CAST Function in MySQL SELECT Statement

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

376 Views

The CAST() function in MySQL converts a value of any type into a value that has a specified type. Let us first create a table −mysql> create table castFunctionDemo    -> (    -> ShippingDate date    -> ); Query OK, 0 rows affected (0.74 sec)Following is the query to insert some records in the table using insert command −mysql> insert into castFunctionDemo values('2019-01-31'); Query OK, 1 row affected (0.20 sec) mysql> insert into castFunctionDemo values('2018-07-12'); Query OK, 1 row affected (0.16 sec) mysql> insert into castFunctionDemo values('2016-12-06'); Query OK, 1 row affected (0.16 sec) mysql> insert ... Read More

Create Stream from a String Byte Array in Java

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

593 Views

Create an input stream and set the string:DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream("pqrs tu v wxy z".getBytes()));The getBytes() method is used to convert a string into sequence of bytes and returns an array of bytes.Now return one single input byte:(char) inputStream.readByte()Exampleimport java.io.ByteArrayInputStream; import java.io.DataInputStream; public class Demo { public static void main(String[] args) throws Exception {    DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream("pqrs tu v wxy z".getBytes()));       System.out.print((char) inputStream.readByte());       System.out.print((char) inputStream.readByte());       inputStream.close();    } }OutputPq

Provider Keys Method in Java

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

140 Views

An enumeration of the keys of the required hash table can be obtained using the keys() method in the class java.security.Provider. This method requires no parameters and it returns the enumeration of the keys of the hash table.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) throws Exception {       try {          Signature sign = Signature.getInstance("DSA");          Provider p = sign.getProvider();          Enumeration enumeration = p.keys();          System.out.println("The enumeration of ... Read More

Remove Data from LinkedHashSet in Android

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

112 Views

This example demonstrate about How to remove data from Linked hashset in AndroidStep 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 the name and record number as Edit text, when user click on save button it will store the data into arraylist. Click on delete ... Read More

Insert Rows into a ResultSet in JDBC

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

1K+ Views

You can retrieve the contents of a table as a ResultSet and, insert a new row to it directly. To do so, first of all, you need to make sure your ResultSet is updatable.The moveToInsertRow() method of the ResultSet interface navigates the cursor to the position where you need to insert the next record. Therefore, move the cursor to the appropriate position to insert a row using this method.The updateXXX() methods of the ResultSet interface allows you to insert/update values into the ResultSet object.Add values to the new row using these methods for example if you need to insert an ... Read More

LocalDateTime withHour Method in Java

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

64 Views

An immutable copy of a LocalDateTime with the hour altered as required is done using the method withHour() in the LocalDateTime class in Java. This method requires a single parameter i.e. the hour that is to be set in the LocalDateTime and it returns the LocalDateTime with the hour altered as required.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main {    public static void main(String[] args) {       LocalDateTime ldt1 = LocalDateTime.parse("2019-02-18T23:15:30");       System.out.println("The LocalDateTime is: " + ldt1);       LocalDateTime ldt2 = ldt1.withHour(5);       ... Read More

Call Stored Procedure with Output Parameters Using JDBC

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

10K+ Views

A. Stored procedures are sub routines, segment of SQL statements which are stored in SQL catalog. All the applications that can access Relational databases (Java, Python, PHP etc.), can access stored procedures.Stored procedures contain IN and OUT parameters or both. They may return result sets in case you use SELECT statements. Stored procedures can return multiple result sets.You can call a stored procedure using the following syntax:CALL procedure_name (input_parameter1, input_parameter2, input_parameter3)JDBC provides a standard stored procedure SQL escape syntax using which you can procedures in all RDBMSsTo call a stored procedure using a JDBC program you need to:Register the driver: ... Read More

Group By One Column and Select All Data in MySQL

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

1K+ Views

Yes, you can use group_concat() for this. Let us first create a table −mysql> create table groupByOneSelectAll    -> (    -> StudentDetails varchar(100),    -> StudentName varchar(100)    -> ); Query OK, 0 rows affected (0.91 sec)Following is the query to insert some records in the table using insert command −mysql> insert into groupByOneSelectAll values('StudentFirstName', 'John'); Query OK, 1 row affected (0.14 sec) mysql> insert into groupByOneSelectAll values('StudentFirstName', 'Chris'); Query OK, 1 row affected (0.21 sec) mysql> insert into groupByOneSelectAll values('StudentFirstName', 'Robert'); Query OK, 1 row affected (0.65 sec) mysql> insert into groupByOneSelectAll values('StudentFirstName', 'Bob'); Query ... Read More

Get First N Characters from a MySQL Column

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

977 Views

Use SUBSTRING() to get first N characters from a MySQL column. Let us first create a table −mysql>create table DemoTable (    Information text ); Query OK, 0 rows affected (2.63 sec)Insert records in the table using insert command −mysql>insert into DemoTable values('MySQL is a structured query language'); Query OK, 1 row affected (0.13 sec)Following is the query to display all records from the table using select statement −mysql>select *from DemoTable;This will produce the following output −+--------------------------------------+ | Information                         | +--------------------------------------+ | MySQL is a structured query ... Read More

Advertisements