 |
|
|
 |
 |
| |
 |
| |
 |
|
| Given
N how many numbers will be there from
1 to N which contains the same number
of 1’s in their binary representation. |
 |
| Example:
given 10, there are 3, 5, 6, 9 (4 numbers)
which have same number of 1’s in their
binary form |
 |
 |
 |
|
| Given
an array A of size N, and two points
I and J (where 0 < i < j <
N) how many minimum writes (to array
locations) are needed to move elements
a[i] to a[j] (both inclusive) to the
beginning of the array. |
 |
Ex: input array a,b,c,d,e,f,g where
N = 7
I = 3, J = 5 |
 |
Result
array d,e,f,a,b,c,g
Writes needed are 6. |
 |
| What
is the minimum number of writes for
any given N, I, J (where 0<i<j<N)?
How? |
 |
 |
 |
|
| Given
a single dimension array of size N which
contains only values X and Y (may be
0, 1) what is the distribution of number
of swaps for all possible values of
array A of size 64 to make the array
sorted. (for all possible values of
A of size 64, distribution of number
of swaps required to make the array
sorted) |
 |
| Ex:
the index of the number that ends with
two 5’s is 9. |
 |
Values
of A swaps needed
0, 0
0
0, 1
0
1, 0
1
1, 1
0 |
 |
Distribution
is 0 swaps 3, 1 swaps 1
Distribution if A of size 4 is 0 swaps
5, 1 swap 10 and 2 swaps 1.
(What is the distribution for A of size
64?) |
 |
 |
 |
|
| There
is an N*N square matrix where N is odd.
The initial values of all the cells
are ‘1’. |
 |
| We
give value X as input to the centre
of the matrix. Each time a value is
given to a cell, it adds that value
to the current cell value and passes
on X-1 to the 8 neighbor cells (side,
diagonal, up, down). They again do the
same stuff till the value X reaches
ZERO. |
 |
Example:
for a 5 X 5 matrix if X is 3 then the
result matrix is
2 3 4
3 2
3 5 7
5 3
4 7 12 7
4
3 5 7
5 3
2 3 4
3 2 |
 |
| What
is the value of the centre cell if X
= 32 for a 7 X 7 matrix? |
 |
 |
 |
|
2
** 20 = 1048576 ( ** is POWER)
What is the next power of 2 that will
end with number 1048576?
2 ** X = ………………………………….1048576, what
is X? |
 |
 |
 |
|
 |
|
|
 |
 |
 |
 |
 |
 |
 |
| Here
are some of the questions that the code4bill contestants
answered. How about trying your hand at them? |
| • |
Multiply
14332 represented in base -7 with 16430 represented
in base -8 and represent the output in base -9. |
| • |
An array
contains 9 occurrences of 0s, 8 occurrences of 1s and
7 occurrences of 2s in any order. The array is to be
sorted using only swap operations. What is the minimum
number of swaps needed in the worst case to sort the
array? |
| • |
You are given an infinite number of cookie boxes containing either 6, 9 or 400 cookies. You are allowed to use these boxes in any combination so desired. What is the maximum number of cookies that you cannot give out using the above boxes? |
|
|
 |
|
 |
|
 |
|
 |
 |
| |
|
|
 |
|
|