In this problem, we are given an array arr[] consisting of n integer values. Our task is to create a program to find the equilibrium index of an array.Equilibrium Index is the index at which the sum of all elements before the index is the same as the sum of all elements after the index.For array arr[] of size n, the equilibrium index is e such that, sum (arr[0… e-1] ) = sum (arr[e… n-1])Let’s take an example to understand the problem, Input: arr[] = {5, 1, 2, 8, 3, 4, 1}Output: 3Explanation: arr[0] + arr[1] + arr[2] = arr[4] + arr[5] + arr[6]=> ... Read More
Equidigital numbers are mathematically special numbers in which the number of digits in the number is equal to the number in its prime factorization.In this problem, we are given an integer value n. Our task is to create a program to all equidigital numbers up to n.Let’s take an example to understand the problem, Input: n = 12Output: 1 2 3 5 7 10 11Solution Approach:A simple solution to the problem would be finding the factors of the number and check if the number of primes is equal to the number of digits in the number .The prime factors can be ... Read More
In this problem, we are given an integer n. Our task is to create a program to find the count of integers from i = 0 to n, where sum is equal to XOR i.e. (n+i) = (n^i).Let’s take an example to understand the problem, Input: n = 4Output: 4Explanation: Considering all values of i from 0 to n, i = 0, 4 + 0 = 4, 4^0 = 4i = 1, 4 + 1 = 5, 4^1 = 5i = 2, 4 + 2 = 6, 4^2 = 6i = 3, 4 + 3 = 7, 4^3 = 7i = 4, ... Read More
In this problem, we are given an array of n elements. Our task is to create a program to count the number of operations to equalize an array using elements only.We need to count the number of adding or subtraction operations that will be performed to make all the elements of the array equal.Let’s take an example to understand the problem, Input: arr[] = {4, 0, 3, 1, 2}Output: 3Explanation: The equal value will be 2.The overall sum will be the same. We will be taking 1 from value at arr[3] and then adding it to value at arr[1].Then we will take 2 ... Read More
In this problem, we are given the coordinates of a polygon. Our task is to create a program to check whether the given polygon is equable or not.Equable Shape is the shape whose perimeter is equal to the area of the shape.Let’s take an example to understand the problem, Input: polygon[][] = {{0, 0}, {5, 7}, {2, 0}}Output: Not equableExplanation: Perimeter = 18.21Area = 7Solution Approach:The solution to the problem lies in find the area and perimeter of the shape and then compare both of them to check weather the given shape is an equable shape or not.Finding a perimeter using the coordinates is ... Read More
Enumeration of Binary Tree is counting the total number of distinct unlabeled binary trees of a given size (specific number of nodes). In this article, we will create a program to count the number of Binary Trees of n nodes.Based on labeling of nodes of binary tree, it is of two types:Labeled Binary TreeUnlabeled Binary TreeLabeled Binary Tree: It is a binary Tree in which the nodes of a tree are labeled with values.Different Type of Labeled Binary Tree for a given number of nodes :Number of nodes N = 2Similarly, We can find the number of distinct labeled binary Tree for ... Read More
Entringer Number is a special number which is equal to the number of permutations of {1, 2, 3, … n+1}, starting with K+1 which is updated by decreasing then increasing the values alternatively.The value of Entringer Number is formulated using, The recurrence relation, E(n, k) = E(n, k-1) + E(n-1, n-k)The base value is, E(0, 0) = 1E(n, 0) = 0We can find the Entringer number using, Let’s take an example to see valuesN = 5, k = 3E(5, 3) = 14Program to illustrate the working of our solution, ExampleLive Demo#include using namespace std; int EntringerNumber(int n, int k) ... Read More
In the binary file and data management, endianness is the sequence of bytes of a digital data inside the computer memory.In computer memory there are two type of endian order,Big-endian system stores the most significant byte of the data.Small-endian systems store the least significant byte of the data.
In this problem, we will understand the conversion of 2-D array to 1-D array. We will see how to store the elements of a 2-D array to a 1-D array.Here, the size of 1-D array is same as the total number of elements in 2-D array which is n*m.In programming there are two ways to store a 2-D array to 1-D array. They are−Row MajorColumn MajorRow Major: In row major, All the elements of a row are stored together then it moves to the next row.If an element of 2-D array of size nXm has an index (i, j) is stored ... Read More
Emirp number is a special type of number that is a prime number whose digits when reversed create another prime number (this prime number is different from the original one).Emirp is the reverse of prime. Some prime numbers that are not emirp are palindromic prime and single digit prime numbers. Some Emirp Numbers are 13, 17, 37, 733.Program to print all emirp numbers less than n.Here, we are given a number n, and we need to print all emirp numbers less than or equal to n.Let’s take an example to understand the problem, Input: n = 40Output: 13, 17, 31, 37Solution ApproachTo find all emirp numbers less ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP