Find Good Feedback Edge Set in a Graph Using C++

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

212 Views

In this Program we will basically find a feedback arc set which contains edges which when removed from the graph, graph becomes directed acyclic graph.AlgorithmBegin function checkCG(int n) : n: number of vertices. arr: struct graph variable. Initialize cnt = 0 and size = (n-1). For i =0 to n-1    if (cnt == size)       return 0    if (arr[i].ptr == NULL)       Increase cnt.       for j = 0 to n-1          while (arr[j].ptr != NULL)             if ((arr[j].ptr)->des == (arr[i].ptr)->des)       ... Read More

Select MySQL Rows in the Order of IN Clause

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

148 Views

You need to use FIND_IN_SET() function to select MySQL rows in the order of IN clause. The syntax is as follows −SELECT yourVariableName.* FROM yourTableName yourVariableName WHERE yourVariableName.yourColumnName IN(value1, value2, ...N) ORDER BY FIND_IN_SET( yourVariableName.yourColumnName, 'value1, value2, ...N');To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table InDemo -> ( -> CodeId int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.95 sec)Insert some records in the table using insert command. The query is ... Read More

ByteBuffer arrayOffset Method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

177 Views

The offset of the first element of the buffer inside the buffer array is obtained using the method arrayOffset() in the class java.nio.ByteBuffer. If the buffer backed by the array is read-only, then the ReadOnlyBufferException is thrown.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { ByteBuffer buffer = ByteBuffer.allocate(5); ... Read More

Create Triplet Tuple from Another Collection in Java

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

128 Views

Use the fromCollection() to create a Triplet tuple from another collection. Here, we will create a tuple from List Collection, but let us first see what we need Let us first see what we need to work with JavaTuples. To work with JavaTuples. Let us first see what we need to work with JavaTuples. To work with Triplet class in JavaTuples, you need to import the following package −import org.javatuples.Triplet;Note − Steps to download and run JavaTuples program If you are using Eclipse IDE to run Triplet Class in JavaTuples, then Right Click Project → Properties → Java Build Path ... Read More

Types of Statements in JDBC

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

11K+ Views

There are three types of statements in JDBC namely, Statement, Prepared Statement, Callable statement.StatementThe Statement interface represents the static SQL statement. It helps you to create a general purpose SQL statements using Java.Creating a statementYou can create an object of this interface using the createStatement() method of the Connection interface.Create a statement by invoking the createStatement() method as shown below.Statement stmt = null; try { stmt = conn.createStatement( ); . . . } catch (SQLException e) { . . . } finally { . . . }Executing the ... Read More

Send HTML Based Email Using JSP Page

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

638 Views

Here is an example to send an HTML email from your machine. It is assumed that your localhost is connected to the Internet and that it is capable enough to send an email. Make sure all the jar files from the Java Email API package and the JAF package are available in CLASSPATH.This example is very similar to the previous one, except that here we are using the setContent() method to set content whose second argument is "text/html" to specify that the HTML content is included in the message.Using this example, you can send as big an HTML content as ... Read More

Instant minusMillis Method in Java

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

218 Views

An immutable copy of a instant where some milliseconds are subtracted from it can be obtained using the minusMillis() method in the Instant class in Java. This method requires a single parameter i.e. the number of milliseconds to be subtracted and it returns the instant with the subtracted milliseconds.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { Instant i = Instant.now(); System.out.println("The current instant is: " + i); ... Read More

LongStream rangeClosed Method in Java

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

313 Views

The rangeClosed() method of the LongStream class in Java returns a sequential ordered LongStream from startInclusive to endExclusive by an incremental step of 1. This is inclusive of the initial element and the last element.The syntax is as follows −static LongStream rangeClosed(long startInclusive, long endExclusive)Here, startInclusive is the first value, whereas the endExclusive is the last.To use the LongStream class in Java, import the following package −import java.util.stream.LongStream;The following is an example to implement LongStream rangeClosed() method in Java −Example Live Demoimport java.util.stream.LongStream; public class Demo { public static void main(String[] args) { ... Read More

Create Key-Value Tuple Using with Method in Java

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

106 Views

To create a KeyValue tuple in Java, you can use the with() method. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package:import org.javatuples.KeyValue;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project → Properties → Java Build Path → Add External Jars  and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples:Steps: How to run JavaTuples program in EclipseThe following is an example to create KeyValue tuple using ... Read More

Test MySQL Elimination of Common Subexpressions Between SELECT and HAVING Group By Clause

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

101 Views

To test, use the sleep() function.Case 1 −The syntax is as follows −SELECT yourColumnName+sleep(yourIntegerValue) FROM yourTableName GROUP BY yourColumnName+sleep(yourIntegerValue);;Case 2 − You can use another syntax which is as follows −SELECT yourColumnName+sleep(yourIntegerValue) As anyAliasName FROM yourTableName GROUP BY yourAliasName;To understand the above syntaxes, let us create a table. The query to create a table is as follows −mysql> create table sleepDemo    -> (    -> value int    -> ); Query OK, 0 rows affected (1.25 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into sleepDemo values(40); Query OK, 1 row ... Read More

Advertisements