Ravi Ranjan has Published 148 Articles

C++ Program to Find kth Largest Element in a Sequence

Ravi Ranjan

Ravi Ranjan

Updated on 18-Apr-2025 16:55:33

386 Views

In this article, we have an unsorted array. Our task is to find the kth maximum element of that array using C++. Here is an example to understand the meaning of k. If k =2, you can say the second highest value, for k =3, the third highest value. The ... Read More

C++ Program to Implement Selection Sort

Ravi Ranjan

Ravi Ranjan

Updated on 17-Apr-2025 16:53:03

22K+ Views

The selection sort is an in-place comparison-based simple sorting algorithm. In the selection sort technique, the list is divided into two parts: sorted and unsorted. The minimum element from the unsorted part is selected and swapped with the element at the beginning of the list. Similarly, the next minimum value ... Read More

C++ Program to Implement Radix Sort

Ravi Ranjan

Ravi Ranjan

Updated on 16-Apr-2025 19:01:43

4K+ Views

The radix sort is a non-comparative sorting algorithm that sorts the individual digits of the given numbers in the list. It sorts the numbers digit by digit, starting from the least significant digit to the most significant digit. The radix sort assumes that all the input elements are k-digit numbers. ... Read More

largest string formed by choosing words from a given Sentence as per given Pattern

Ravi Ranjan

Ravi Ranjan

Updated on 16-Apr-2025 15:58:58

287 Views

To find the largest string formed by choosing words from a given sentence, a user should know about the lexicographically largest string. A lexicographically largest string is a string, when sorted alphabetically, it would appear at the last if we form all possible strings from the selected words. For example: ... Read More

C++ Program to Implement Insertion Sort

Ravi Ranjan

Ravi Ranjan

Updated on 15-Apr-2025 19:19:13

19K+ Views

The insertion sort technique is an in-place comparison-based sorting algorithm used to sort the numbers in an ascending or descending order. It is similar to the card sorting technique. In this technique, we pick up one element from the data set and shift the data elements to make a place ... Read More

Why is the size of an empty class not zero in C++?

Ravi Ranjan

Ravi Ranjan

Updated on 15-Apr-2025 17:31:12

2K+ Views

The size of an empty class is not zero in C++ as it allocates one unique address to the object in the memory. The size can not be 0, because the two classes can not have the same memory address. So, the size of an empty class is 1 byte ... Read More

C++ Program to Find Minimum Element in an Array using Linear Search

Ravi Ranjan

Ravi Ranjan

Updated on 15-Apr-2025 15:28:30

972 Views

Linear search is a sequential searching algorithm where we traverse every element within the input array and compare it with the key element to be found. The minimum element refers to the smallest element in the array. In this article, we have an array of integers. Our task is to ... Read More

C Program to print numbers from 1 to N without using semicolon

Ravi Ranjan

Ravi Ranjan

Updated on 15-Apr-2025 15:27:59

2K+ Views

Printing numbers from 1 to N is an easy task that can be achieved using loops, but to print numbers from one to N without using a semicolon is a tricky question. We will discuss two different methods to solve this question using iteration and recursion approaches. In this article, ... Read More

C Program to sum the digits of a given number in single statement

Ravi Ranjan

Ravi Ranjan

Updated on 15-Apr-2025 15:27:34

557 Views

The calculation of the sum of the digits of a number in a single statement means that only one line of code will be doing the addition operation. The addition operation should not extend more than one statement. In this article, we have a number and our task is to ... Read More

C++ Program to Emulate N Dice Roller

Ravi Ranjan

Ravi Ranjan

Updated on 15-Apr-2025 15:27:13

1K+ Views

Emulating an n dice roller refers to rolling n number of dice simultaneously. In each roll, all the dice will return a different value from 1 to 6. In this article, we are having 'n' number of dices, our task is to emulate rolling n dices simultaneously. The approaches are ... Read More

Advertisements