
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
Server Side Programming Articles - Page 2146 of 2651

179 Views
Suppose we have a rectangle ABCD, but we have only the coordinates of the mid points P and Q, and the length of the rectangle L.Our task is to find the coordinates of A, B, C and D using the coordinates of P and Q, and the length of side L. For example, if P is (1, 0), and Q is (1, 2), and L is 2, then A, B, C, D will be respectively (0, 0), (0, 2), (2, 2). (2, 0).There can be three cases that can occur.The rectangle is horizontal, so AD and BC are parallel to ... Read More

204 Views
Suppose two person wants to choose different cities, they have listed out the cities in different list, we have to help the, to find common choices. So we need to find those cities, those are marked by both of them.This operation is very similar to the set intersection property, we will take two lists as set, then perform the set intersection to get the common elements.Example Live Demo#include #include #include using namespace std; vector commonInterest(string set1[], int n1, string set2[], int n2) { vector v(min(n1, n2)); vector::iterator it; // Sorting both the list sort(set1, ... Read More

218 Views
Suppose we have two strings A and B, and another two cost values like CostA, and CostB. We have to find the minimum cost to make A and B identical. We can delete characters from string, the cost for deleting from string A is CostA, and cost for deleting from string B is CostB. Cost of removing all characters from a string is same. Suppose the string A = “wxyz”, B = “wyzx”, CostA is 10 and CostB is 20. So the output will be 30. If we delete x from both the strings, then A and B will be ... Read More

166 Views
Suppose we have two numeric strings A and B. We have to find the minimum cost to make A and B identical. We can perform only one operation, that is we can delete digits from string, the cost for deleting a digit from number is same as the digit value. Suppose the string A = “6789”, B = “7859”, Then we have to delete 6 from A, and delete 5 from B, so the cost will be 5 + 6 = 11.This is one of the variation of Longest Common Subsequence problem. We have to find the length of LCS ... Read More

152 Views
Suppose we have a string. We have to minimize the sum of ASCII values, of each character to the string, after removing every occurrence of a particular character. Suppose a string is given like “hello” the sum of ASCII characters is (104 + 101 + 108 + 108 + 111) = 532. Now check occurrences of each characters.h has occurred one time, so cost is 1 * 104 = 104e has occurred one time, so cost is 1 * 101 = 101l has occurred one time, so cost is 2 * 108 = 216o has occurred one time, so cost ... Read More

393 Views
Consider we have an array of size n, we have to find the Median and Mode using the counting sort technique. This technique is useful, when the array elements are in limited range. Suppose the elements are {1, 1, 1, 2, 7, 1}, then the Mode is 1, and Median is 1.5. Let us see what is Median and what is Mode −Median is the middle number in a sorted list of numbersMode is the element whose occurrences are maximum in the listTo get the Median and Mode, we have to follow these steps −Assume that the size of the ... Read More

521 Views
Here we will see some MCQ questions on Memory Allocation and Compilation Processes.Question 1 − What will be the output of the following code − Live Demo#include #include int main() { union my_union { int i; float f; char c; }; union my_union* u; u = (union my_union*)malloc(sizeof(union my_union)); u->f = 20.60f; printf("%f", u->f); }Options −Garbage Value20.600000Syntax Error20.6ExplanationUsing unions, we can use same memory location to hold multiple type of data. All member of union uses same memory location which has maximum space. Here ... Read More

1K+ Views
In this article, we have an array of integers. Our task is to find the maximum sum of a sub-array using divide and conquer algorithm. A sub-array is a continuous part of an array with consecutive array elements. For example: {2, 3, 4} is sub-array of {1, 2, 3, 4, 5} but {1, 4, 5} is not. What is Divide and Conquer Algorithm? The Divide and Conquer algorithm divides a problem into smaller sub-problems, and then each sub-problem is solved independently. We keep dividing the sub-problems till we reach a stage where no more division ... Read More

234 Views
Suppose we have a complete graph; we have to count number of Edge Disjoint Spanning trees. The Edge Disjoint Spanning trees are spanning trees, where no two trees in the set have an edge in common. Suppose the N (number of vertices) is 4, then output will be 2. The complete graph using 4 vertices is like below −Two edge disjoint spanning trees are like −The maximum number of edge disjoint spanning tree from a complete graph, with N vertices will be $[\frac{n}{2}]$Example#include #include using namespace std; int maxEdgeDisjointSpanningTree(int n){ return floor(n/2); } int main() { int n = 4; cout

900 Views
Suppose we have two different arrays. We have to sort one array based on the other array using C++ STL pair class. Consider two arrays are like A1 = [2, 1, 5, 4, 9, 3, 6, 7, 10, 8], and another array is like A2 = [A, B, C, D, E, F, G, H, I, J], The output will be like: A1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], A2 = [B, A, F, D, C, G, H, J, E, I]Here we are using the pairs of C++ STL. The pair is formed by taking one ... Read More