Server Side Programming Articles - Page 2182 of 2650

C++ Program for Longest Common Subsequence

sudhir sharma
Updated on 19-Sep-2019 07:16:44

3K+ Views

A subsequence is a sequence with the same order of the set of elements. For the sequence “stuv”, the subsequences are “stu”, “tuv”, “suv”, .... etc.For a string of length n, there can be 2n ways to create subsequence from the string.ExampleThe longest common subsequence for the strings “ ABCDGH ” and “ AEDFHR ” is of length 3. Live Demo#include #include using namespace std; int max(int a, int b); int lcs(char* X, char* Y, int m, int n){    if (m == 0 || n == 0)       return 0;    if (X[m - 1] == ... Read More

C++ program for hashing with chaining

sudhir sharma
Updated on 19-Sep-2019 07:13:39

2K+ Views

Hashing is the method by which we can map any length data element to a fixed size key. hashing works as key-value pairs.Hashing function is the function that does the mapping in a hash map. the data elements that are given as input to the Hash Function may get same hash key. In this case the elements may overlap. To avoid overlapping of elements which have the same hash key the concept of chaining was introduced.Creating a hashmapIn order to create a hashmap we need hashing function that will define the index value of the data element.We have a hash ... Read More

C++ Mathematical Functions

sudhir sharma
Updated on 19-Sep-2019 07:05:50

3K+ Views

Mathematical calculations can be done in C++ programming language using the mathematical functions which are included in math or cmath library. These mathematical functions are defined to do complex mathematical calculations. Let’s learn each of them one by one −sineThe sin method is used to calculate the sin of the angle given as an argument in degrees. This function accepts one double integer as an argument and returns a double integer which is the value of sin(x°).double sin(double)Calling syntaxdouble x = sin(23.4);Example Live Demo#include #include using namespace std; int main(){    double x = 45.3;    cout

C++ map having key as a user defined data type

sudhir sharma
Updated on 19-Sep-2019 06:52:55

1K+ Views

A map is a data structure that stores information in the form of key and value pairs. In C++, map is defined in STL (standard template library) and store keys in an ordered form.Syntax to define a map −map map_name;The data type of any of these two data of the map can be any of the data types. We can have any of the primary data types or derived data types as key or value data types in a map.We can use any of the data types as the data type of the key of the map. Even a user-defined ... Read More

C++ interview questions on virtual function and abstract class

sudhir sharma
Updated on 19-Sep-2019 06:44:52

1K+ Views

What is a virtual function?A virtual function is a method that does not have a definition when defined in the base class. This method is left black in the parent class and it is redefined in the child class.What is an abstract class?An abstract class is a class that has abstract members or at least one pure virtual function in its definition. An abstract class can never be instanced (creating an object). It can only be inherited and the methods could be overwritten.Can there be any virtual Destructors?Yes, These are legal in C++, but these are destructors are for base ... Read More

Difference between continue and break statements in Java

Alshifa Hasnain
Updated on 21-Mar-2025 19:08:32

9K+ Views

As we know in programming execution of code is done line by line. Now in order to alter this flow Java provides two statements break and continue which are mainly used to skip some specific code at specific lines. Difference Table Following are the important differences between continue and break − Sr. No. Key ... Read More

Difference between Compile Time Errors and Runtime Errors in C Program

Nitin Sharma
Updated on 18-Sep-2019 11:49:02

2K+ Views

Error or exception is something that refers to the interruption of code execution due to which the expected outcome could not be attained to the end-user.On the basis of the event when an error is generated or identified we can classify them as Compile time error and runtime error.The following are the important differences between Compile Time Errors and Runtime Errors.Sr. No.KeyCompile Time ErrorsRuntime Errors1ReferenceCompile-time errors are generally referred to the error corresponding to syntax or semantics.Runtime errors on the other hand refer to the error encountered during the execution of code at runtime.2DetectionCompile-time errors get detected by compiler at ... Read More

Difference between Boxing and Unboxing in C# programming.

Nitin Sharma
Updated on 17-Sep-2019 11:06:03

1K+ Views

C# provides two methods to link value type to reference type and vice e Versa. These two methods for linking are named boxing and unboxing where Boxing is used for the conversion of the value type to an object type while Unboxing refers to the conversion of the object type to the value type.The following are the important differences between Boxing and Unboxing.Sr. No.KeyBoxingUnboxing1ImplementationBoxing made object type referred to as the value type.Unboxing basically processes the retrieving value from the boxed object.2StorageIn the case of boxing, the value stored on the stack is copied to the object stored on heap ... Read More

Python Program for simple interest

Pavitra
Updated on 11-Sep-2019 13:21:02

2K+ Views

In this article, we will learn about the calculation of simple interest in Python 3.x. Or earlier.Simple interest is calculated by multiplying the daily interest rate by the principal amount by the number of days that elapse between the payments.Mathematically, Simple Interest = (P x T x R)/100 Where, P is the principal amount T is the time and R is the rateFor example, If P = 1000, R = 1, T = 2 Then SI=20.0 Now let’s see how we can implement a simple interest calculator in Python.Example Live DemoP = 1000 R = 1 T = 2 # simple ... Read More

Python Program for Selection Sort

Pavitra
Updated on 11-Sep-2019 13:18:05

2K+ Views

In this article, we will learn about the Selection sort and its implementation in Python 3.x. Or earlier.In the selection sort algorithm, an array is sorted by recursively finding the minimum element from the unsorted part and inserting it at the beginning. Two subarrays are formed during the execution of Selection sort on a given array.The subarray, which is already sortedThe subarray, which is unsorted.During every iteration of selection sort, the minimum element from the unsorted subarray is popped and inserted into the sorted subarray.Let’s see the visual representation of the algorithm −Now let’s see the implementation of the algorithm ... Read More

Advertisements