This is a C++ Program to Implement the Edmonds-Karp algorithm to calculate maximum flow between source and sink vertex.Algorithm:Begin function edmondsKarp() : initiate flow as 0. If there is an augmenting path from source to sink, add the path to flow. Return flow. EndExample Code#include #include #include #include #include using namespace std; int c[10][10]; int flowPassed[10][10]; vector g[10]; int parList[10]; int currentPathC[10]; int bfs(int sNode, int eNode)//breadth first search { memset(parList, -1, sizeof(parList)); memset(currentPathC, 0, sizeof(currentPathC)); queue q;//declare queue vector q.push(sNode); parList[sNode] = -1;//initialize parlist’s ... Read More
This example demonstrate about How to create firebase account for android applicationRegister with firebase account using https://firebase.google.com/Click on Sign in button, it will ask gmail user name and pass word as shown below –Give proper user name and pass word. After successful login process, it will redirect to main page as shown below –Now click on go to console, it will redirect to create project as shown below –Now click on add project, it will ask project details as shown belowGive project name and accept all terms and conditions as shown below –After enter all details click on create project.it ... Read More
For converting array to 1D and 2D arrays, let us first create a one-dimensional and two-dimensional array −One-DimensionalString str[] = {"p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};Two-Dimensionaldoubled [][]= { {1.2, 1.3, 2.1, 4.1}, {1.5, 2.3}, {2.5, 4.4}, {3.8}, {4.9}, {3.2, 2.1, 3.2, 7.2} };Converting array to string for one-dimensional array −Arrays.toString(str);Converting array to string for two-dimensional array −Arrays.deepToString(d);Exampleimport java.util.Arrays; public class Demo { public static void main(String args[]) { String str[] = {"p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}; ... Read More
The free() function is used to deallocate memory while it is allocated using malloc(), calloc() and realloc(). The syntax of the free is simple. We simply use free with the pointer. Then it can clean up the memory.free(ptr);The free() is not taking any size as parameter, but only pointer. So the question comes, that how the free() function know about the size of the block to deallocate?When we use the dynamic memory allocation techniques for memory allocations, then this is done in the actual heap section. It creates one word larger than the requested size. This extra word is used ... Read More
In this program we will see how to multiply using logical operators.Problem StatementWrite 8085 Assembly language program to multiply two 8-bit numbers using logical operators.DiscussionWe are assuming the first number is in register B, and second number is in register C, and the result must not have any carry.Here we are multiplying with 04H. We can perform the multiplication by left rotate two times. Assign 06H into B, and 04H into C. Load B to A, then rotate the accumulator two times. Store the result into a specified memory.InputRegisterDataB06C04Flow Diagram ProgramAddressHEX CodesLabelsMnemonicsCommentsF00006, 06 MVI B, 06H F0020E, 04 MVI C, 04H F00478 MOV A, BLoad B ... Read More
The getValueX() method is used to get a value from Quartet Tuple class in Java at a particular index. For example, getValue0().Let us first see what we need to work with JavaTuples. To work with Quartet class in JavaTuples, you need to import the following package −import org.javatuples.Quartet;Note − Steps to download and run JavaTuples program. If you are using Eclipse IDE to run Quartet 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.Quartet; public class Demo { ... Read More
This action lets you insert files into the page being generated. The syntax looks like this −Unlike the include directive, which inserts the file at the time the JSP page is translated into a servlet, this action inserts the file at the time the page is requested.Following table lists out the attributes associated with the include action −S.No.Attribute & Description1pageThe relative URL of the page to be included.2flushThe boolean attribute determines whether the included resource has its buffer flushed before it is included.ExampleLet us define the following two files (a)date.jsp and (b) main.jsp as follows −Following is the content of ... Read More
The day of the month for a particular LocalDateTime can be obtained using the getDayOfMonth() method in the LocalDateTime class in Java. This method requires no parameters and it returns the day of the month which can be in the range of 1 to 31.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalDateTime ldt = LocalDateTime.parse("2019-02-18T11:30:15"); System.out.println("The LocalDateTime is: " + ldt); System.out.println("The day of ... Read More
The boxed() method of the LongStream class returns a Stream consisting of the elements of this stream, each boxed to a Long.The syntax is as follows.Stream boxed()Here, Stream represents a sequence of elements. To use the LongStream class in Java, import the following package.import java.util.stream.LongStream;Create an IntStream and add some elements in a range using the range() method.LongStream intStream = LongStream.range(20800L, 20805L);Now, use the boxed() methodStream s = intStream.boxed();The following is an example to implement LongStream boxed() method in Java.Example Live Demoimport java.util.stream.Stream; import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream intStream ... Read More
You can use update() function to insert records in MongoDB if it does not exist. To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.insertIfNotExistsDemo.insertOne({"StudentName":"Mike", "StudentAge":21}); { "acknowledged" : true, "insertedId" : ObjectId("5c7eec7b559dd2396bcfbfc2") } > db.insertIfNotExistsDemo.insertOne({"StudentName":"Sam", "StudentAge":22}); { "acknowledged" : true, "insertedId" : ObjectId("5c7eec97559dd2396bcfbfc3") }Display all documents from a collection with the help of find() method. The query is as follows −> db.insertIfNotExistsDemo.find().pretty(); The following is the output: { "_id" : ObjectId("5c7eec7b559dd2396bcfbfc2"), "StudentName" : "Mike", "StudentAge" : ... Read More