Server Side Programming Articles - Page 1240 of 2650

Find the Intersection Point of Two Linked Lists in Java

Dev Prakash Sharma
Updated on 23-Feb-2021 18:42:34

653 Views

A Linked List is a linear data structure in which each node has two blocks such that one block contains the value or data of the node and the other block contains the address of the next field.Let us assume that we have a linked list such that each node contains a random pointer which is pointing to the other nodes in the list. The task is to find the node at which two linked lists intersect each other. If they don’t intersect, then return NULL or empty as output.For ExampleInput-1:Output:2Explanation: Since the given linked list intersects at the node with ... Read More

Significance of regex match() and regex search() function in Python

Dev Prakash Sharma
Updated on 23-Feb-2021 05:50:24

639 Views

There are two types of operations that can be performed using regex, (a) search and (b) match. In order to use regex efficiently while finding the pattern and matching with the pattern, we can use these two functions.Let us consider that we have a string. regex match() checks the pattern only at the beginning of the string, while regex search() checks the pattern anywhere in the string. The match() function returns the match object if a pattern is found, otherwise none.match() – Finds the pattern only at the beginning of the string and returns the matched object.search() – Checks for ... Read More

Python Program to Construct an Expression Tree of a given Expression

Dev Prakash Sharma
Updated on 23-Feb-2021 18:49:16

3K+ Views

Expression trees are those in which the leaf nodes have the values to be operated, and the internal nodes contain the operator on which the leaf node will be performed.Example: 4 + ((7 + 9) * 2) will have an expression tree like -Approach to solve this ProblemIn order to construct an Expression Tree for a given expression, we generally use Stack Data Structure. Initially we Iterate over the given postfix expression and follow the steps as given below -If we get an operand in the given expression, then push it in the stack. It will become the root of the ... Read More

Make three numbers Zero in Python

Dev Prakash Sharma
Updated on 23-Feb-2021 18:56:04

327 Views

Let us suppose we have three numbers. The task is to count the total number of optimal steps to make all these numbers '0'.For ExampleInput-1:a = 4 b = 4 c = 6Output:7Explanation:The total number of optimal steps to make all the numbers '0' is, (4, 4, 6)Removing '1' from 1st and 2nd number = (3, 3, 6)Removing '1' from 1st and 3rd number = (2, 3, 5)Removing '1' from 1st and 3rd number = (1 ,3, 4)Removing '1' from 1st and 3rd number = (0 ,3 ,3)Removing '1' from 2nd and 3rd number = (0 ,2, 2)Removing '1' from ... Read More

Largest Merge of Two Strings in Python

Dev Prakash Sharma
Updated on 23-Feb-2021 19:01:14

318 Views

Let us suppose we have two strings 'a' and 'b' and a string 'merge'. The task is to fill the string 'merge' with the characters from 'a' and 'b' in such a way that, If the string 'a' is non-empty, then remove the first character from the string 'a' and copy it into string 'merge'.If the string 'b' is non-empty, then remove the first character from the string 'b' and copy it into string 'merge'.If the strings 'a' and 'b' are non-empty, then remove the first characters from string 'a' and copy it into string 'merge' and then remove the ... Read More

Explain pointers and one-dimensional array in C language

Bhanu Priya
Updated on 17-Mar-2021 10:21:38

8K+ Views

Pointer is a variable that stores the address of another variable.FeaturesThe features of pointer are explained below −Pointer saves the memory space.Execution time of pointer is faster because of direct access to the memory location.With the help of pointers, the memory is accessed efficiently, i.e., memory is allocated and deallocated dynamically.Pointers are used with data structures.Pointer declaration, initialization and accessingConsider the following statement −int qty = 179;In memory, the variable can be represented as follows −Declaring a pointerIt means ‘p’ is a pointer variable which holds the address of another integer variable, as mentioned in the statement below −Int *p;Initialization ... Read More

How to send individual elements as an argument in C language?

Bhanu Priya
Updated on 17-Mar-2021 10:02:07

211 Views

The array is a group of related items that is stored with a common name.Declaring arrayThe syntax used for declaring an array is as follows −datatype array_name [size];InitializationAn array can be initialized in two ways, which are as follows −Compile time initializationRuntime initializationAn array can also be initialized at the time of declaration as follows −int a[5] = {100, 200, 300, 400, 500};FunctionA function is a self-contained block that carries out a specific well-defined task. The two ways of passing the arrays as arguments to functions are as follows −Sending an entire array as argument to function.Sending the individual elements ... Read More

Explain the scope rules related to the statement blocks in C language

Bhanu Priya
Updated on 15-Mar-2021 15:21:54

204 Views

The scope rules are related to the following factors −Accessibility of a variables.Period of existence of a variable.Boundary of usage of variables.Scope rules related to statement blocks are given below −Block is enclosed in curly braces which consists of set of statements.Variables declared in a block are accessible and usable within that block and does not exist outside it.Example 1Following is the C program for scope rules related to statement blocks − Live Demo#include main ( ){    {       int i = 1;       printf ("%d", i);    }    {       int j=2;   ... Read More

What is a two-dimensional array in C language?

Bhanu Priya
Updated on 15-Mar-2021 15:11:52

4K+ Views

An array is a group of related items that store with a common name.SyntaxThe syntax is as follows for declaring an array −datatype array_name [size];Types of arraysArrays are broadly classified into three types. They are as follows −One – dimensional arraysTwo – dimensional arraysMulti – dimensional arraysInitializationAn array can be initialized in two ways, which are as follows −Compile time initialization.Runtime initialization.Two multidimensional arraysThese are used in situations where a table of values have to be stored (or) in matrices applications.SyntaxThe syntax is given below −datatype array_ name [rowsize] [column size];For example int a[5] [5];a[0][0]10a[0][1]20a[0][2]30a[1][0]40a[1][1]50a[1][2]60a[2][0]a[2][1]a[2][2]Following is the C Program for ... Read More

What is a one-dimensional array in C language?

Bhanu Priya
Updated on 15-Mar-2021 15:06:17

12K+ Views

An array is a group of related items that store with a common name.SyntaxThe syntax is as follows for declaring an array −datatype array_name [size];Types of arraysArrays are broadly classified into three types. They are as follows −One – dimensional arraysTwo – dimensional arraysMulti – dimensional arraysOne – dimensional arrayThe Syntax is as follows −datatype array name [size]For example, int a[5]InitializationAn array can be initialized in two ways, which are as follows −Compile time initializationRuntime initializationExampleFollowing is the C program on compile time initialization − Live Demo#include int main ( ){    int a[5] = {10, 20, 30, 40, 50};   ... Read More

Advertisements