Found 25152 Articles for Server Side Programming

Modelling the Secant Method in Python

Dr Pankaj Dumka
Updated on 15-Mar-2023 17:05:48
Secant method is one of the powerful methods to know the x-intercept (zeros) of a polynomial or any transcendental function. In this method, first we select (basically guess) the interval in which we expect the root ($\mathrm{π‘₯_{1}}$, $\mathrm{π‘₯_{2}}$). Then we draw a secant line to join the points on the function (A, B) corresponding to the guessed values as shown in the figure below. The secant line intersects the x-axis at the point $\mathrm{π‘₯_{3}}$, as $\mathrm{π‘₯_{3}}$ and $\mathrm{π‘₯_{2}}$ are not close (i.e., their absolute difference is finite) we find the point corresponding to π‘₯3 on the curve i.e., C. ... Read More

Modelling the Regula Falsi Method in Python

Dr Pankaj Dumka
Updated on 15-Mar-2023 16:46:15
In this tutorial, I will show you how to find the roots of an equation with the help of Regula Falsi which is also called as the "False Position Method". Let us consider the figure shown below. First we have searched for two π‘₯ values $\mathrm{x_{1}}$ and $\mathrm{x_{2}}$ at which the value of function ($\mathrm{y_{1}} $and $\mathrm{y_{2}}$) are different, means the points should be such that the products of these two should be negative (i.e. they should lie on the opposite sides of the X-axis). As these are not the exact point i.e. the points at which root exist, ... Read More

Modelling the Newton Raphson Method in Python

Dr Pankaj Dumka
Updated on 15-Mar-2023 16:13:20
In this tutorial, I will show you how to evaluate the roots of a polynomial or transcendental equation with the help of a numerical method known as the Newton Raphson method. This is an iterative method in which we start with a initial guess (of independent variable) and then evaluate the new value of π‘₯ based on the guess. And the process goes on till the convergence is achieved. The method is explained with the help of a diagram as shown below. Based on $x_{g}$ the value of function $(f^{'} \left ( x_{g} \right ))$ is evaluated. Then a ... Read More

Sentence Case of a given Camel cased String

Mallika Gupta
Updated on 15-Mar-2023 11:35:16
A C++ string is a collection of characters forming words. It may contains letters, numbers and even special characters. The sentences of a string can be clubbed together in different ways to form different types of representations. The camel case of a string denotes the string in such a way that the following two properties are maintained βˆ’ The words are joined together, there is no space character. Every word has the first letter stored in upper case. Thereby, the upper case letters in this form of representation can be used to segregate the different words. This type ... Read More

Reverse Individual Words With O(1) Extra Space

Mallika Gupta
Updated on 15-Mar-2023 11:32:48
A string may be composed of several words. Every word in a C++ string may contain letters, numbers or special symbols. Strings are considered to be storage elements for these kind of characters. Each word is separated by a space character. Each word also forms a string of characters. Reverse of any string in C++ is the string follows the following points βˆ’ It is formed by taking characters from the end towards the beginning. The length of the original string remains unchanged. The order of occurrence of characters in a string can be reversed easily by swapping ... Read More

Rearrange the given string such that all Prime Multiple indexes have Same Character

Mallika Gupta
Updated on 15-Mar-2023 11:21:57
A string is a sequence of characters, numbers, Alphanumeric characters and special characters. The length of a string is the number of characters that are present in it. A prime number is the number which is divisible by 1 and the number itself. In this artice, we are given a sample input string of length n. We are going to develop a code where the idea is to substitute the same character at any position p, such that the the characters at positions ranging from 1 to n/p should coincide. Some of the examples illustrating the problem statement ... Read More

Minimum Number of Adjacent Awaps to Convert a String into its given Anagram

Mallika Gupta
Updated on 15-Mar-2023 11:15:35
Every string is formed by a sequence of characters arranged in an order. The string may be composed of letters, number or even special characters. An anagram of any input string, is the string with a random permutation of characters. This implies, that when the order of the characters is rearranged, an anagram of the string is obtained. The respective counts of the characters should also remain the same in anagrams. Two anagram strings have the following implications βˆ’ Both of them contains the same set of characters. Both of them may have a different permutation of characters ... Read More

Make Given Binary Strings Equal by Replacing Two Consecutive 0s with Single1 Repeatedly

Mallika Gupta
Updated on 15-Mar-2023 11:12:06
A binary string in any programming language is a collection of characters, 0 and 1. At every stage, the binary string follows the approach that the string can contain only these two characters. Consecutive characters in strings are the characters such that the difference in indices is 1. Let us consider two indices, i and j , they are said to be consecutive, if |j-i| = 1. Two strings in C++ are said to be equivalent if βˆ’ The corresponding characters in both the strings are same. The length of the strings are equal as well as the characters ... Read More

Find distinct characters in distinct substrings of a string

Mallika Gupta
Updated on 15-Mar-2023 10:39:39
A string is a sequence of characters, numbers and special characters. A string may contain multiple substrings. A substring of a given string is any sequence of characters taken in order. It must satisfy the following properties All the characters should be taken from the input string The indexes taken from the original string should be contiguous. The characters can’t be skipped from between. It may eliminate characters from the original string. All the characters taken from a particular string should be consecutive in nature. However, each substring may be composed of same or different characters. In this ... Read More

Count of non-overlapping sub-strings β€œ101” and β€œ010” in the given binary string

Mallika Gupta
Updated on 15-Mar-2023 10:33:58
A binary string is a sequence of characters comprising of 0’s and 1’s only. A binary string can’t contain any other character. Some of the examples of binary strings are β€œ0000”, ”01010” or β€œ11111” A substring of a given string is a sequence of characters taken in order. A string may contain multiple substrings. Non-overlapping strings are the strings where the indices of any two found substrings should not collide with each other. This implies that for any two substrings substr1[a..b] and substr2[c..d], either of the following, bd should be true. The problem statement involves the computation of the ... Read More