Ravi Ranjan has Published 148 Articles

Can main function call itself in C++?

Ravi Ranjan

Ravi Ranjan

Updated on 13-May-2025 19:34:44

2K+ Views

The main() function can call itself in C++. This is an example of recursion, i.e., a function calling itself. In recursion, a function calls itself over and over again with modified arguments until it reaches its base case or the termination condition, where the recursion stops. In this article, we ... Read More

What is the meaning of prepended double colon “::” in C++?

Ravi Ranjan

Ravi Ranjan

Updated on 13-May-2025 19:34:31

8K+ Views

The prepended double colon (::) is also known as the scope resolution operator. The scope resolution operator serves various purposes in C++. In this article, we will discuss the applications of the scope resolution operator in C++ with example codes of each application. Uses of Scope Resolution Operator in ... Read More

C++ static member variables and their initialization

Ravi Ranjan

Ravi Ranjan

Updated on 13-May-2025 19:34:21

6K+ Views

The static member variables in C++ are defined using the static keyword. The static member variables in a class are shared by all the class objects as there is only one copy of them in memory, regardless of the number of objects of the class. All static data is initialized ... Read More

C++ Program for QuickSort?

Ravi Ranjan

Ravi Ranjan

Updated on 12-May-2025 16:52:36

2K+ Views

Quick sort algorithm is also known as partition exchange sort and is based on partitioning of an array of data into smaller sub-arrays. A large array is partitioned into two arrays such that the left sub-array holds values smaller than the pivot element and the ... Read More

C++ Program to Perform the Shaker Sort

Ravi Ranjan

Ravi Ranjan

Updated on 12-May-2025 16:50:32

2K+ Views

Shaker sort is a variation of bubble sort and is both a stable and comparison based sorting algorithm. The shaker sort is also known as cocktail sort or bidirectional bubble sort as it sorts the array in both directions. In this article, we have an unsorted array. Our task is ... Read More

C++ Program to Perform Stooge Sort

Ravi Ranjan

Ravi Ranjan

Updated on 12-May-2025 16:50:14

335 Views

Stooge Sort is a recursive sorting algorithm used to sort the given data. The stooge sort divides the array into two overlapping parts, 2/3 each and then sort the array in three steps by sorting first then second and again first part. The worst case time complexity of this algorithm ... Read More

C++ Program to Implement the linear congruential generator for Pseudo Random Number Generation

Ravi Ranjan

Ravi Ranjan

Updated on 08-May-2025 18:49:19

1K+ Views

The Linear Congruential Generator (LCG) is a very simple technique to generate a sequence of numbers that looks like random numbers but is actually determined. It is one of the reasons to call it a pseudo-random number. The Linear Congruential Generator (LCG) technique generates a random number based on the ... Read More

C++ Program to Implement Sorting of Less than 100 Numbers in O(n) Complexity

Ravi Ranjan

Ravi Ranjan

Updated on 08-May-2025 18:49:07

350 Views

To sort less than 100 numbers in O(N) complexity, we can use the counting sort technique. The counting sort is a stable and non-comparison-based sorting technique, that is used to sort the objects according to the keys that are small integers. It counts the number of keys whose key values ... Read More

C++ Program to Implement Merge Sort Algorithm on Linked List

Ravi Ranjan

Ravi Ranjan

Updated on 08-May-2025 18:48:55

2K+ Views

The merge sort technique is based on the divide-and-conquer technique. We divide the whole data set into smaller parts and merge them into a larger piece in sorted order. It is also very effective for worst cases because this algorithm has lower time complexity for worst cases too. A ... Read More

C++ Program to Implement Counting Sort

Ravi Ranjan

Ravi Ranjan

Updated on 08-May-2025 18:48:44

4K+ Views

Counting sort is a stable and non-comparison-based sorting technique, that is used to sort the objects according to the keys that are small integers. It counts the number of keys whose key values are same. It works by counting the occurrences of elements in the array. This sorting technique is ... Read More

Advertisements