Divya Sahni has Published 42 Articles

Check if a given string is a comment or not

Divya Sahni

Divya Sahni

Updated on 25-Jul-2023 12:53:09

991 Views

In computer programming, comments are text written with the source code but ignored by the compiler or interpreter. They are used to provide readability of code by describing the code and its functionality for someone who is reading the code other than a compiler or interpreter. They are not executed ... Read More

Total area of two overlapping rectangles

Divya Sahni

Divya Sahni

Updated on 25-Jul-2023 12:50:15

610 Views

An overlapping area is an area that is shared by two objects. In the case of rectangles, it is the area of the rectangles that belong to both rectangles. In order to find the total areas of two overlapping rectangles, first er need to add the area of both rectangles ... Read More

Sum of Pairwise Products

Divya Sahni

Divya Sahni

Updated on 25-Jul-2023 12:47:33

546 Views

The pairwise product of a set X = {a, b, c} can be defined as the sum of the product of all possible set pairs. The pairs of the set are, Y = {a * a, a * b, a *c, b * b, b * c, c * c}, ... Read More

Heap Sort for decreasing order using min heap

Divya Sahni

Divya Sahni

Updated on 25-Jul-2023 12:44:09

560 Views

Heap Sort − Heap sort is a comparison-based algorithm that used binary tree data structures to sort a list of numbers in increasing or decreasing order. It heap sorts to create a heap data structure where the root is the smallest element and then removes the root and again sorting ... Read More

Golomb sequence

Divya Sahni

Divya Sahni

Updated on 25-Jul-2023 12:38:15

363 Views

Golomb Sequence − The Golomb Sequence is a non-decreasing sequence of integers where the value of the nth term is the number of times the integer n appeared in the sequence. Some terms of Golomb sequence are, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, ... Read More

Front and Back Search in unsorted array

Divya Sahni

Divya Sahni

Updated on 25-Jul-2023 12:35:32

167 Views

Unsorted Array − An array is a data structure consisting of a collection of elements of the same type. An unsorted array is such a structure where the order of elements is random, i.e. on insertion, the element is added to the last irrespective of the order of previous elements ... Read More

Find n-th Fortunate Number

Divya Sahni

Divya Sahni

Updated on 25-Jul-2023 12:32:59

101 Views

Fortunate Numbers − It is the smallest integer m > 1 such that, for a given positive integer n, pn# + m is a prime number, where pn# is the product of the first n prime numbers. For example, for calculating the third fortunate number, first calculate the product of ... Read More

Check if the given two numbers are friendly pairs or not

Divya Sahni

Divya Sahni

Updated on 25-Jul-2023 12:25:24

384 Views

Friendly Numbers − According to number theory, friendly numbers are two or more numbers having the same abundancy index. Abundancy Index − Abundancy index of a natural number can be defined as the ratio between the sum of all the divisors of the natural number and the natural number itself. ... Read More

Check if any valid sequence is divisible by M

Divya Sahni

Divya Sahni

Updated on 25-Jul-2023 12:20:14

68 Views

A sequence is a collection of objects, and in our case, it is a collection of integers. The task is to find if a sequence with the usage of the addition and subtraction operator within the elements is divisible by M or not. Problem Statement Given an integer M and ... Read More

XNOR of two numbers

Divya Sahni

Divya Sahni

Updated on 25-Jul-2023 12:16:12

297 Views

XNOR(Exclusive-NOR) gate is a digital logic gate that takes two inputs and gives one output. Its function is the logical complement of the Exclusive-OR (XOR) gate. The output is TRUE if both inputs are the same and FALSE if the inputs are different. The truth table of the XNOR gate ... Read More

Advertisements