Sudhir sharma has Published 1206 Articles

Fast average of two numbers without division in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2021 13:30:31

315 Views

In this problem, we are given two numbers A and B. Our task is to create a program to calculate the Fast average of two numbers without division. Let’s take an example to understand the problem, Input: A = 34       B = 54Output: 44Solution Approach: Normally, the average is calculated by ... Read More

Extended Midy's theorem in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2021 13:26:20

82 Views

Midy’s Theorem is a statement used for decimal expansion of numbers denoted by n/p, where n is any number and p is a prime number and a/p has a repeating decimal with even period.In Extended Midy’s Theorem, the repeating portion is divided into m digits, then their sum is a ... Read More

Expression Tree with Example in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2021 13:26:00

332 Views

An expression tree is a special type of binary tree in which each node of the tree either consists of an operator or operand.Leaf nodes of the tree represent an operand.Non-leaf nodes of the tree represent an operator.Example:To get the infix expression which can be easily solved, we need to ... Read More

Express an odd number as sum of prime numbers in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2021 13:25:36

294 Views

In this problem, we are given an odd number N. Our task is to express an odd number as the sum of prime numbers.There can be at max three prime numbers while expressing the number.Let’s take an example to understand the problem, Input: N = 55Output: 53 + 2Solution Approach: The odd number ... Read More

Evil Number with Example in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2021 13:17:29

548 Views

In this problem, we are given an array a number N. Our task is to check whether the number is an evil Number or Odious Number. Evil Number: It is a positive number which has an even number of 1’s in its binary expansion.Example: 5, 17 Odious Number: It is a positive number which ... Read More

Evaluation of Risk in Investments in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2021 13:16:43

96 Views

In this problem, we are given two arrays each denoting an investment plan. Our task is to perform the evaluation of Risk in Investment and find which of the two investments is more promising.Both the investments I1[][] and I2[][] has a set of outcomes and the probability of that investment outcome.Using ... Read More

Evaluation order of operands in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2021 13:16:32

167 Views

There are some rules in programming that govern how an operation is performed.The order of evaluation of operation and the associativity of operations (which is left to right is defined).Here is a program to show the evaluation order of operands, ExampleLive Demo#include using namespace std; int x = 2; ... Read More

Even-odd turn game with two integers in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2021 13:16:29

193 Views

In this problem, we are given three integer values A , B and T. Our task is to create a program to play Even-odd turn game with two integers. The two integer value are :T, that denotes the number of turns in the game.A denotes the value for player1B denotes the ... Read More

Even numbers at even index and odd numbers at odd index in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2021 13:16:18

872 Views

In this problem, we are given an array arr[] of size n consisting of n/2 even values and n/2 odd values. Our task is to create a program to place even numbers at even index and odd numbers at odd index. Let’s take an example to understand the problem, Input: arr[] = ... Read More

Even size subtree in n-ary tree in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2021 13:15:47

104 Views

In this problem, we are given an adjacency list that denotes an n-ary tree. Our task is to find the number of even size subtree in n-ary tree. N-ary tree is defined as a collection of nodes normally represented hierarchically in the following manner.The tree is started at the root node.Each node ... Read More

Advertisements