Programming Articles

Page 2515 of 2547

Time Functions in Python?

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 15K+ Views

Python provides library to read, represent and reset the time information in many ways by using “time” module. Date, time and date time are an object in Python, so whenever we do any operation on them, we actually manipulate objects not strings or timestamps.In this section we’re going to discuss the “time” module which allows us to handle various operations on time.The time module follows the “EPOCH” convention which refers to the point where the time starts. In Unix system “EPOCH” time started from 1 January, 12:00 am, 1970 to year 2038.To determine the EPOCH time value on your system, ...

Read More

C++ Program to Implement The Edmonds-Karp Algorithm

Daniol Thomas
Daniol Thomas
Updated on 30-Jul-2019 4K+ Views

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

Java Program to convert array to String for one dimensional and multi-dimensional arrays

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 424 Views

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

What is the function of action in JSP?

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 532 Views

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

C++ Program to Implement First Fit Decreasing for 1-D Objects and M Bins

Nancy Den
Nancy Den
Updated on 30-Jul-2019 225 Views

Here is a C++ Program to implement First Fit Decreasing for 1-D objects and M binsRequired functions and pseudocode:Begin    function binPack() returns number of bins required.    Initialize binC = 0    Initialize an array to store binVal.    Place items one by one.    function sort() to perform bubble sort in the descending order. EndExample Code#include using namespace std; void binPack(int *a, int s, int n) {    int binC = 0;    int binVal[n];    for (int i = 0; i < n; i++)    binVal[i] = s;    for (int i = 0; i < ...

Read More

What are JSP declarations? In how many ways we can write JSP declarations?

Samual Sam
Samual Sam
Updated on 30-Jul-2019 348 Views

A declaration declares one or more variables or methods that you can use in Java code later in the JSP file. You must declare the variable or method before you use it in the JSP file.Following is the syntax for JSP Declarations −You can write the XML equivalent of the above syntax as follows − code fragment Following is an example for JSP Declarations −

Read More

Create Ennead Tuple from another collection in Java

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 176 Views

To create Ennead Tuple from another collection, use the fromCollection() method. Using this method, create an Ennead Tuple using List collection. Let us first see what we need to work with JavaTuples. To work with Ennead class in JavaTuples, you need to import the following package.import org.javatuples.Ennead;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 ...

Read More

C++ Program to Compare Binary and Sequential Search

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 699 Views

Binary Search and Sequential or Linear Search both are used in computer programming to search an element. The time complexity of Binary Search is O(log(n)) and Sequential Search is O(n).AlgorithmBegin    Algorithm for Binary Search:    BinarySearch() function with ‘arr’ the array of data and ‘n’ the number of values, start and end index, iteration count and element to be searched in the argument list.    Increment iteration counter and compare the item value with the a[mid].    If item < a[mid] choose first half otherwise second half to proceed further.    Return iteration value on successful search. EndExample Code#include ...

Read More

How to declare an object of a class using JSP declarations?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 1K+ Views

A declaration declares one or more variables or methods that you can use in Java code later in the JSP file. You must declare the variable or method before you use it in the JSP file.Following is the syntax for JSP Declarations −You can write the XML equivalent of the above syntax as follows − code fragment Following is an example of Object declaration in JSP Declarations −

Read More

How are variables scoped in C

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 144 Views

Here we will see how the C variables are scoped. The variables are always statically scoped in C. Binding of a variable, can be determined by the program text. These are independent of runtime function call stack.Let us see one example to get the idea.Example# include int x = 0; int my_function() {    return x; } int my_function2() {    int x = 1;    return my_function(); } int main(){    printf("The value is: %d", my_function2()); }OutputThe value is: 0Here the result is 0. Because the value returned by my_function() is not depends on the function, which is ...

Read More
Showing 25141–25150 of 25,467 articles
Advertisements