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 1673 of 2650
206 Views
In this problem, we are given 3 array X, Y, Z. Our task is to create a program to find the Sum of special triplets having elements from 3 arrays.Special Triplet is a special type of triplet that hold the following property −For (a, b, c): a ≤ b and b ≥ c, i.e the middle element of the triplet should be greeter that the other two.And, the value of the triplet is given by the formula −f(a, b, c) = (a+b) * (b+c)To create this triplet we need to use one element from each other the three arrays given.Let’s ... Read More
143 Views
In this problem, we are given a linked list with a node consisting of two values and a pointer. Our task is to create a program to find the sum of smaller elements of a node in a linked list.Here, in the linked list we have two elements say X and Y. The program will find a minimum of x and y. The minimum elements from all nodes are added which is the required result.Input −(5, 2)->(7, 9)->(6, 3)->(36, 24)->(19, 26)->nullOutput −55Explanation −Let’s take the minimum of X and Y from each node −node1 - mini = 5 node2 - ... Read More
1K+ Views
The block swap algorithm for array rotation is an efficient algorithm that is used for array rotation. It can do your work in O(n) time complexity.So, in array rotation, we are given an array arr[] of size n and a number k that define the no. of the element to be rotated.Let’s see an example on array rotations −Input −arr[] = {4, 6, 1, 8, 9, 2}, k = 2 (number of rotations.)Output −{1, 8, 9, 2, 4, 6}Explanation − On rotation, we will shift the one element to the last position and shift the next elements to one position.Element ... Read More
360 Views
BK tree or Burkhard tree is a form of a data structure usually used to perform spell checks based on Levenshtein distance. It is also used for string matching Autocorrect feature can be used making this data structure. Let's say we have some words in a dictionary and we need to check some other words for spelling errors. We need to have a collection of words that is close to the given word whose spelling is to be checked. For example, if we have the word “uck” The correct word can be (truck, duck, duck, suck). Therefore spelling mistakes can ... Read More
847 Views
In this problem, we are given a number N. Our task is to find all prime numbers smaller than N using Bitwise Sieve.Bitwise sieve is an optimized version of Sieve of Eratosthenes which is used to find all prime numbers smaller than the given number.Let’s take an example to understand the problem, Input − N = 25Output − 2 3 5 7 11 13 17 19 23The bitwise sieve works in the same ways as the normal sieve. It just we will use the bits of integers of represent primes instead of a boolean type. This will reduce the space ... Read More
4K+ Views
In this problem, we are given two numbers. Our task is to create a C program for the Bitwise recursive addition of two integers.The logic to find the sum using the Bitwise operations is similar to what we used to do when we were in preschool. For finding the sum, we used to add each digit of the number and if a carry is there, we add it to the next digit.We will do a similar thing, find the sum using the XOR operator and check for the carry using the AND operation. If there is a carry we will ... Read More
366 Views
In this problem, we are given an array bin[] of size n of binary strings. Our task is to create a program to find the Bitwise OR (&) of n binary strings.Here, we will take all numbers and find the bitwise AND of them i.e. bin[0] | bin[1] |... bin[n-2] | bin[n]Let’s take an example to understand the problem, Input −bin[] = {“1001”, “11001”, “010101”}Output −011101Explanation − Bitwise OR of all binary string −(1001) | (11001) | (010101) = 011101To solve this problem, We will simply find the string with the largest number of bits (max length string). Then we ... Read More
1K+ Views
In this problem, we are given two integer values a and b. And our task is to find the bitwise OR (|) of range from a to b. This means we will have to find the value of a | a+1 | a+2 | … b-1 | b.Let’s take an example to understand the problem, Input − a = 3 , b = 8Output − 15Explanation − 3 | 4 | 5 | 6 | 7 | 8 = 15To solve the problem, a simple solution is starting from a and find bit-wise OR of all numbers by increasing one ... Read More
1K+ Views
In this problem, we are given an array arr[] of size n and an integer k. Our task is to find the subarray within from index i to j and compute bitwise AND of all its elements. After this print minimum value of abs(K- (bitwise AND of subarray)).Let’s take an example to understand the problem, Input − arr[] = {5, 1}, k = 2Output −To solve the problem, there can be a few methods.One simple solution will be using the direct method. By finding bitwise AND for all sub-arrays then finding the |K-X|.Step 1 − Find the bitwise AND for ... Read More
225 Views
In this problem, we are given two integer values a and b. And our task is to find the bitwise and (&) of range from a to b. This means we will have to find the value of a & a+1 & a+2 & … b-1 & b.Let’s take an example to understand the problem, Input − a = 3 , b = 8Output − 0Explanation − 3 & 4 & 5 & 6 & 7 & 8 = 0To solve the problem, a simple solution is starting from a and find bitwise and of all numbers by increasing one ... Read More