
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
Found 26504 Articles for Server Side Programming

1K+ Views
The Selection Sort algorithm sorts an exhibit by more than once finding the base component from the unsorted part and putting it toward the start. In each emphasis of determination sort, the base component from the unsorted subarray is picked and moved to the arranged subarray.Example Live Demo#include #include using namespace std; #define MAX_LEN 50 void selectionSort(char arr[][50], int n){ int i, j, mIndex; // Move boundary of unsorted subarray one by one char minStr[50]; for (i = 0; i < n-1; i++){ // Determine minimum element in unsorted array ... Read More

140 Views
Problem statementLucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. The task is to find minimum lucky number has the sum of digits equal to n.ExampleIf sum = 22 then lucky number is 4477 as 4 + 4 + 7 + 7 = 22Algorithm1. If sum is multiple of 4, then result has all 4s. 2. If sum is multiple of 7, then result has all 7s. 3. If sum is not multiple of 4 or 7, then we can subtract one of them till sum becomes multiple of other.Example Live ... Read More

227 Views
The stable_sort method of STL first sorts the components with name as the key in ascending order and afterward the components are arranged with their segment as the key. Moreover, The stable_sort() calculation is viewed as steady in light of the fact that the overall request of comparable components is kept up. Here is the source code of the C++ program which exhibits the stable_sort() calculation demonstrated as follows;Example Live Demo#include using namespace std; int main(){ int arr[] = { 11, 15, 18, 19, 16, 17, 13, 20, 14, 12, 10 }; int n = sizeof(arr) / sizeof(arr[0]); stable_sort(arr, arr + n); cout

104 Views
Problem statementGiven N numbers from 1 to N and a number S. The task is to print the minimum number of numbers that sum up to give SExampleIf n = 7 and s = 10 then minimum 2 numbers are required(9, 1) (8, 2) (7, 3) (6, 4)AlgorithmAnswer can be calculated using below formula (S/N) + 1 if { S %N > 0}Example Live Demo#include using namespace std; int getMinNumbers(int n, int s) { return s % n ? s / n + 1 : s / 2; } int main() { int n = 7; int s = 10; cout

232 Views
Problem statementWe have an integer N. We need to express N as a sum of K integers such that by adding some or all of these integers we can get all the numbers in the range 1 to N. The task is to find minimum value of KExampleIf N = 8 then final answer i.e. K would be 3If we take integers 1, 2, 3, and 4 then adding some or all of these groups we can get all number in the range 1 to Ne.g. 1 = 1 2 = 2 3 = 3 4 = 4 5 = ... Read More

2K+ Views
Problem statementGiven an array with n positive integers. We need to find the minimum number of operation to make all elements equal. We can perform addition, multiplication, subtraction or division with any element on an array element.ExampleIf input array is = {1, 2, 3, 4} then we require minimum 3 operations to make all elements equal. For example, we can make elements 4 by doing 3 additions.Algorithm1. Select element with maximum frequency. Let us call it ‘x’ 2. Now we have to perform n-x operations as there are x element with same valueExample Live Demo#include using namespace std; int getMinOperations(int *arr, ... Read More

418 Views
Stein's Algorithm used for discovering GCD of numbers as it calculates the best regular divisor of two non-negative whole numbers. It replaces division with math movements, examinations, and subtraction. In the event that both an and b are 0, gcd is zero gcd(0, 0) = 0. The algorithm for GCD(a, b) as follows;AlgorithmSTART Step-1: check If both a and b are 0, gcd is zero gcd(0, 0) = 0. Step-2: then gcd(a, 0) = a and gcd(0, b) = b because everything divides 0. Step-3: check If a and b are both even, gcd(a, b) = 2*gcd(a/2, ... Read More

340 Views
Problem statementGiven an integer K and a matrix of M x N, the task is to find the minimum number of operations required to make all the elements of the matrix equal. In a single operation, K can be added to or subtracted from any element of the matrix.ExampleIf input matrix is: { {2, 4}, {20, 40} } and K = 2 then total 27 operations required as follows; Matrix[0][0] = 2 + (K * 9) = 20 = 9 operations Matrix[0][1] = 4 + (k * 8) = 20 = 8 operations Matrix[1][0] = 20 + (k ... Read More

943 Views
This sample draft calculates the total number of words in a given string as well as counts the total occurrence of a particular word using stringstream in the C++ programming code. The stringstream class partners a string object with a stream enabling you to peruse from the string as though it were a stream. This code shall achieve two feats, first, it will count the total number of words then calculates the frequencies of individual words subsequently in a string using the map iterator essential methods as follows;Example Live Demo#include using namespace std; int totalWords(string str){ stringstream s(str); ... Read More

2K+ Views
Problem statementGiven an array with n positive integers. We need to find the minimum number of operation to make all elements equal. We can perform addition, multiplication, subtraction or division with any element on an array element.ExampleIf input array is = {1, 2, 3, 4} then we require minimum 3 operations to make all elements equal. For example, we can make elements 4 by doing 3 additions.Algorithm1. Select element with maximum frequency. Let us call it ‘x’ 2. Now we have to perform n-x operations as there are x element with same valueExample Live Demo#include using namespace std; int ... Read More