Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 1999 of 3366
657 Views
In this problem, we are given an array. Our task is to check whether a number generated by using all digits of the elements of the array is divisible by 3. If possible then print “Yes” otherwise print “No”.Let’s take an example to understand the problemInput − arr = {3, 5, 91, }Output − YESExplanation − The number 5193 is divisible by 3. So, our answer is YES.To solve this problem, we will check its divisibility by 3.Divisibility by 3 − a number is divisible by 3 if the sum of its digits is divisible by 3.Now, we will have ... Read More
98 Views
In this problem, we are given two integer N and D. Our task is to check whether it is possible to have to sets from the set of first N natural numbers that have a difference of D.Let’s take an example to understand the problem, Input − N=5 D =3Output − YesExplanation −Out of 1, 2, 3, 4, 5. We can have two sets set1= {1, 2, 3} and set2 = {4, 5}, this will give difference 3. {4+5} - {1+2+3} = 9- 6 = 3For solving this problem, we will have some mathematical calculations.We know, the sum of all number ... Read More
5K+ Views
In this problem, we are given expression in postfix form and our task is to print the infix form of the expression.Infix expression is an expression in which the operator is in the middle of operands, like operand operator operand.Postfix expression is an expression in which the operator is after operands, like operand operator.Postfix expressions are easily computed by the system but are not human readable. So this conversion is required. Generally reading and editing by the end-user is done on infix notations as they are parenthesis separated hence easily understandable for humans.Let’s take an example to understand the problemInput ... Read More
742 Views
In this problem, we are given a binary tree and node. Our task is to print the postorder successor of the node in Binary tree.Binary tree is a special type of tree in which each node can have at max 2 child nodes.Postorder Traversal is a tree traversal technique, in which the first left subtree is traversed than the right subtree and the root is traversed at the end.postorder traversal of the above tree: 8 4 2 7 9 6Let’s take an example to understand the problem.Input − binary tree in above example, node= 7Output − 9Explanation − we can ... Read More
467 Views
In this problem, we are given a Binary tree. Our task is to print the postorder traversal of the binary tree without using recursion and without stack.Binary tree is a special type of tree in which each node can have at max 2 child nodes.Postorder Traversal is a tree traversal technique, in which the first left subtree is traversed than the right subtree and the root is traversed at the end.postorder traversal of the above tree − 8 4 2 7 9 6To traverse the tree without using recursion and stack. We will depth-first search based technique and data will ... Read More
724 Views
pow() or power function is a function used to calculate the power of a number. It is generally used in real numbers. Here, we will see its implementation of complex numbers.Complex numbers are those numbers that can be represented as A + iB, where A is the real part and B is the complex part of the number.The functions for the complex number in c++ are defined in the header file . Here, the pow() method for complex numbers is defined. It finds the complex power of a complex number to some power.The method is applied to complex numbers takes ... Read More
179 Views
The power of a number is the times a number is multiplied to itself. Also knows as exponent or indices.a to the power b is b times a is multiplied by itself b times. 7 to the power 2 is 72 also known as 7 square is valued 49.Some common power values are −A number to the power 0 gives 1.A number to the power 1 gives the same number, as stated some multiplied once is the same.A number to the negative power is n times division. Example, a -3 = 1/a3 or (1/a)*(1/a)*(1/a)Now, let’s do some programming based on ... Read More
230 Views
In this problem, we are given two integer n and r. Our task is to find the power of the given prime number r in the factorial of the number n.Let’s take an example to understand the problemInput − n = 6 r = 2Output − 4Explanation −Factorial n, 6! = 6*5*4*3*2*1 = 720 720 = 24 * 32 * 5, power of 2 is 4To solve this problem, a simple solution would be directly finding the factorial and then finding the power of the prime number. But this is not the best solution.Another efficient solution is using a formula, ... Read More
777 Views
In this problem, we are given string str. Our task is to print the power set of this string’s elements in lexicographical order.Power Set − The power set of a set is the set of all subsets of the set. Denoted by P(S) where s is the set.Example −S = {1, 2, 3} ; p(S) = {{}, {1}, {1, 2}, {1, 3}, {2}, {2, 3}, {3}, {1, 2, 3}}In this problem, we will treat the string as a set. So, its characters will be the elements of the set.Let’s take an example to understand the problemInput − str = “xyz”Output ... Read More
689 Views
In this problem, we are given an integer N. Our task is to print the number which when raised to the power of 2 gives the number.Let’s take an example to understand the problemInput − 17Output − 0, 4Explanation − 17 = 24 + 20 = 16 + 1To solve this problem, we will divide the number with 2 recursively. By this method, every number can be represented as a power of 2. This method is used to convert the number to its binary equivalent.ExampleThe program to show the implementation of our solution Live Demo#include using namespace std; void sumPower(long ... Read More