All Strings of N bits
Labels: Programming
Find the repeated element
Given n elements find all the elements that appear morethan n/2 times.
Solve the same for elements appear n/4 times.
Should not use more than const memory and O(n) time.
Prime pairs
Pairs of primes separated by a single number are called prime pairs.
Examples are 17 and 19.
Prove that the number between a prime pair is always divisible by 6 (assuming both numbers in the pair are greater than 6).
Sort the array with 0s and 1s
You are given an Array of N size. It contains 0s and 1s only. You have to arrange all 0s before all 1s and you are not allowed to travel more than once through the array.
Store all receiving samples..
Given that you are receiving samples from an instrument at a constant rate, and you have constant storage space, how would you design a storage algorithm that would allow me to get a representative readout of data, no matter when I looked at it? In other words, representative of the behavior of the system to date.
Multiply by 7..
Multiple by 8 without using multiplication or addition. Now do the same with 7.
Labels: Easy Puzzles
Count number of 1s..
Count the number of set bits in a number. Now optimize for speed. Now optimize for size.
Circular linked list..
Implement an algorithm to insert a node into a circular linked list without traversing it.