Arnab Chakraborty has Published 4293 Articles

A backtracking approach to generate n bit Gray Codes ?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

494 Views

In this section we will see how we can generate the gray codes of n bits using backtracking approach? The n bit gray code is basically bit patterns from 0 to 2^n – 1 such that successive patterns differ by one bit. So for n = 2, the gray codes ... Read More

A permutation where each element indicates either number of elements before or after it?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

113 Views

In this section we will see one problem. Here n elements are given in an array. We have to check whether there is a permutation of that array exists, such that each element indicates the number of elements present either before or after it.Suppose the array elements are {2, 1, ... Read More

A Problem in Many Binary Search Implementations?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

141 Views

We know that the binary search algorithm is better than the linear search algorithm. This algorithm takes O(log n) amount of time to execute. Though most of the cases the implemented code has some problem. Let us consider one binary search algorithm function like below −Exampleint binarySearch(int array[], int start, ... Read More

A Program to check if strings are rotations of each other or not?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

923 Views

Here we will see one program that can tell whether two strings are rotation of each other or not. The rotation of strings is like −Suppose two strings are S1 = ‘HELLO’, and S2 = ‘LOHEL’ So they are rotation of each other. By rotating HELLO three position to the ... Read More

A sorting algorithm that slightly improves on selection sort?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

287 Views

Here we will see some improvements on selection sort. As we know that the selection sort works by taking either the minimum or maximum element from the array and place that element at correct position. In this approach, we want to sort the array in both ways. Here we will ... Read More

Absolute difference between sum and product of roots of a quartic equation?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

319 Views

In this section we will see how to get the absolute difference between the sum of the roots and the products of the root of a quartic equation?The quartic equation is like 𝑎𝑥4+𝑏𝑥3+𝑐𝑥2+𝑑𝑥+𝑒We can solve the equation and then try to get the product and sum of the roots by ... Read More

Absolute difference between the first X and last X Digits of N?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

444 Views

Here we will see how to get the differences between first and last X digits of a number N. The number and X are given. To solve this problem, we have to find the length of the number, then cut the last x digits using modulus operator. After that cut ... Read More

Absolute Difference between the Product of Non-Prime numbers and Prime numbers of an Array?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

208 Views

Here we will see how we can find the absolute difference between the product of all prime numbers and all non-prime numbers of an array. To solve this problem, we have to check whether a number is prime or not. One possible way for primality testing is by checking a ... Read More

Absolute Difference between the Sum of Non-Prime numbers and Prime numbers of an Array?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

230 Views

Here we will see how we can find the absolute difference between the sum of all prime numbers and all non-prime numbers of an array. To solve this problem, we have to check whether a number is prime or not. One possible way for primality testing is by checking a ... Read More

Absolute distinct count in a sorted array?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

193 Views

In this section we will see how to count how many of elements whose absolute values are distinct? Suppose in an array there are few elements like {5, 5, 6, -5, 8, 2, -2, 1}, so there are 8 elements. But there are 5 elements {5, 6, 8, 2, 1} ... Read More

Advertisements