
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 33676 Articles for Programming

315 Views
ConceptWith respect of a given set of elements, determine which permutation of these elements would result in worst case of Merge Sort?We know, asymptotically, merge sort always consumes O(n log n) time, but the cases that need more comparisons generally consume more time in practice. Now we basically require determining a permutation of input elements that would lead to largest number of comparisons when sorted implementing a typical Merge Sort algorithm.Example Consider the below set of elements as Sorted array 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26Resultant input array that will result ... Read More

232 Views
ConceptWith respect of a given Balanced Binary Search Tree and a target sum, we write a function that returns true if there is a pair with sum equals to target sum, otherwise return false. In this case, expected time complexity is O(n) and only O(Logn) extra space can beimplemented. Here, any modification to Binary Search Tree is not permitted.We have to note that height of a Balanced BST is always O(Logn).ExampleMethodAccording to the Brute Force Solution, we consider each pair in BST and verify whether the sum equals to X. The time complexity of this solution will be O(n^2).Now a ... Read More

275 Views
ConceptWith respect of given array Arr[] of non-negative integers, the task is to determine an integer X such that (Arr[0] XOR X) + (Arr[1] XOR X) + … + Arr[n – 1] XOR X is minimum possible.Input Arr[] = {3, 4, 5, 6, 7}Output X = 7, Sum = 10ApproachSo we will verify ‘i’th bit of every number of array in binary representation and consider and count those numbers containing that ‘i’th bit set to ‘1’ because these set bits will contribute to maximize the sum instead of minimize. As a result of this, we have to build this set ‘i’th bit ... Read More

362 Views
Suppose we have an array of n numbers; we have to find a non-empty subset such that the sum of elements of the subset is divisible by n. So, we have to output any such subset with its size and the indices of elements in the original array when it is present.So, if the input is like [3, 2, 7, 1, 9], then the output will be [2], [1 2].To solve this, we will follow these steps −Define one map my_mapadd := 0for initialize i := 0, when i < N, update (increase i by 1), do −add := (add ... Read More

152 Views
Suppose we have a string S. The length is n. These n boxes adjacent to each other, a character R at position i represents that i-th box is being pushed towards right. similarly, L at position i represents that i-th box is being pushed towards left, a dot '.' indicates an empty space. Starting from initial configuration, at every time unit, a box being pushed to the right side is able to push next box to right, same action can be applied for the left side also. We have to find the final positions of all boxes when no more ... Read More

681 Views
ConceptNow the header file graphics.h contains fillpoly() function which is implemented to draw and fill a polygon such as triangle, rectangle, pentagon, hexagon etc. So this function require same arguments as drawpoly().Syntaxvoid fillpoly( int number, int *polypoints );In this case, number indicates (n + 1) number of points where, n is the number of vertices in a polygon and polypoints points to a sequence of (n*2) integers.Input arr[] = {320, 150, 400, 250, 250, 350, 320, 150};Output Explanation So the declaration of fillpoly() contains two arguments: number specifies (n + 1) number of points where n is indicated as the number of vertices ... Read More

167 Views
Suppose we want to place 1, 2, 3, 4, 5, 6, 7, 8, into the eight circles in the given figure, in this way that no number is adjacent to a number that is next to it in the sequence.So, if the input is like0-1-10-1-1-1-10-1-10then the output will beTo solve this, we will follow these steps −N := 3, M := 4NOTCONSIDERED := -1Define a function present_in_grid(), this will take grid[N][M], num, for initialize i := 0, when i < N, update (increase i by 1), do:for initialize j := 0, when j < M, update (increase j by 1), ... Read More

375 Views
ConceptWith respect of given positive number n, the task is to verify if n is a primorial prime number or not. We have to print ‘YES’ if n is a primorial prime number otherwise print ‘NO.Primorial Prime − With respect of Mathematics, a Primorial prime is defined as a prime number of the form pN# + 1 or pN# – 1 , where pN# is the primorial of pN such that the product of first N prime numbers.Input − n = 7Output − YES7 is Primorial prime of the form pN + 1 for N=2, Primorial is 2*3 = 6 ... Read More

213 Views
ConceptWith respect of given positive integer n, the task is to verify if n is an Achilles number or not. We have to print 'YES' if N is treated as an Achilles number else print 'NO'.Achilles number: With respect of Mathematics, an Achilles number is defined as a number that is powerful (A number N is said to be Powerful Number if it has been noted that for every prime factor p of it, p^2 also divides it) but not a perfect power.In following, the first few Achilles number are displayed72, 108, 200, 288, 392, 432, 500, 648, 675, 800, ... Read More

141 Views
ConceptWith respect of given number n, the task is to verify whether n is a Trojan Number or not. Trojan Number is defined as a number that is a strong number without a perfect power. We can say that a number n is treated as a strong number if, for every prime divisor or factor p of n, p^2 is also a divisor. We can say in another way, every prime factor appears at least twice. We should remember that all Trojan numbers are strong. But it is not true for vice-versa that means, not all strong numbers are Trojan ... Read More