Ravi Ranjan has Published 148 Articles

C++ Program to Implement Shell Sort

Ravi Ranjan

Ravi Ranjan

Updated on 07-May-2025 18:37:21

2K+ Views

The shell sorting technique is based on the insertion sort. In the insertion sort, sometimes we need to shift a large block to insert an item in the correct position. In shell sort, we avoid large number of shifting. The sorting is done with specific interval. After each pass, the ... Read More

C++ Program to Implement Segmented Sieve to Generate Prime Numbers Between Given Range

Ravi Ranjan

Ravi Ranjan

Updated on 07-May-2025 18:36:53

1K+ Views

The Segmented Sieve algorithm is used to find the prime numbers within a given range. Segmented Sieve first uses the Sieve of Eratosthenes algorithm to find the primes smaller than or equal to √(n). The idea of this algorithm is to divide the range [0 ... n-1] in different segments ... Read More

C++ Program to Implement Extended Euclidean Algorithm

Ravi Ranjan

Ravi Ranjan

Updated on 07-May-2025 14:10:09

2K+ Views

The extended euclidean algorithms find the greatest common divisor (GCD) of two numbers in the form of ax + by = gcd(a, b). This expression is also known as Bezout's Identity. The extended Euclidean algorithm is an extension of the Euclid algorithm that is also used to find the GCD ... Read More

C++ Program to Implement the Rabin-Miller Primality Test to Check if a Given Number is Prime

Ravi Ranjan

Ravi Ranjan

Updated on 06-May-2025 19:01:02

1K+ Views

Rabin-Miller algorithm is a probabilistic primality test algorithm that is used to checks if a given number is likely to be a prime number or not. It is similar to the Fermat's primality test and the Solovay-Stressen test. In this article, we have a number 'p'. Our task is to ... Read More

C++ Program to Generate Prime Numbers Between a Given Range Using the Sieve of Sundaram

Ravi Ranjan

Ravi Ranjan

Updated on 06-May-2025 19:00:51

599 Views

The Sieve of Sundaram method is used to generate the prime number within the given range. In this method, first we mark the indices with prime number using the mathematical formula. Then, we use the unmarked indices to get the prime numbers within the given range. In this article, we ... Read More

C++ Program to Implement Wheel Sieve to Generate Prime Numbers Between Given Range

Ravi Ranjan

Ravi Ranjan

Updated on 05-May-2025 18:42:57

436 Views

The wheel Sieve method is used to find the prime numbers within a given range. Wheel factorization is a graphical method for manually performing a preliminary to the Sieve of Eratosthenes that separates prime numbers from composites. In this method, prime numbers in the innermost circle have their multiples ... Read More

C++ Program to Implement Sieve of Atkin to Generate Prime Numbers Between Given Range

Ravi Ranjan

Ravi Ranjan

Updated on 05-May-2025 18:42:43

602 Views

The Sieve of Atkin is a modern algorithm for finding all prime numbers up to a specified integer. It follows three simple steps to find the prime numbers. It uses three quadratic expressions that remove the composite numbers. After this, we remove the multiples of squares of already existing prime ... Read More

C++ Program to Implement Sieve of eratosthenes to Generate Prime Numbers Between Given Range

Ravi Ranjan

Ravi Ranjan

Updated on 05-May-2025 18:42:30

3K+ Views

The Sieve of Eratosthenes algorithm is one of the most efficient ways to find prime numbers smaller than n when n is smaller than around 10 million. It follows a simple process of marking the multiples of already prime numbers as false i.e. non-prime numbers. In this article, we have ... Read More

0/1 Knapsack using Branch and Bound in C/C++?

Ravi Ranjan

Ravi Ranjan

Updated on 05-May-2025 12:29:17

3K+ Views

In the 0-1 knapsack problem, a set of items is given, each with a weight and a value. We need to determine the number of each item to include in a collection so that the total weight is less than or equal to the given limit and the total value ... Read More

C++ Program to Generate Random Numbers Using Multiply with Carry Method

Ravi Ranjan

Ravi Ranjan

Updated on 05-May-2025 12:28:21

368 Views

The multiply-with-carry method is a variant of the add-with-carry generator introduced by Marsaglia and Zaman (1991). The main advantages of this method are that it invokes simple computer integer arithmetic and leads to a very fast generation of sequences of random numbers with immense periods, ranging from around 260 to ... Read More

Advertisements