# Recent questions tagged isi2014

1
Let $m$ and $n$ be two integers such that $m \geq n \geq 1.$ Count the number of functions $f : \{1, 2, \ldots , n\} \to \{1, 2, \ldots , m\}$ of the following two types: strictly increasing; i.e., whenever $x < y, f(x) < f(y),$ and non-decreasing; i.e., whenever $x < y, f(x) ≤ f(y).$
2
Let $X_1,X_2,X_3,X_4$ be i.i.d. random variables each assuming the value $1$ and $-1$ with probability $\dfrac{1}{2}$ each. Then, the probability that the matrix $\begin{pmatrix}X_1 &X_2\\ X_3 &X_4\end{pmatrix}$ is nonsingular equals $1/2$ $3/8$ $5/8$ $1/4$
3
Read the C code given below. What would be the output of the following program? Justify your answer. #include <stdio.h> int myrecurse(int a, int b){ return (b == 1 ? a: myrecurse(a, b-1) + a); } main() { int a[]= {2,3,4,5,6}; int i, x; ... . Give an $O(n log n)$ algorithm to determine whether the given sequence $S$ has a subsequence whose sum is zero, and justify the correctness of the algorithm.
4
Let $A$ be a 30 40 matrix having 500 non-zero entries. For $1 \leq i \leq 30$, let $r_i$ be the number of non-zero entries in the $i$-th row, and for $1 \leq j \leq 40$, let $m_j$ be the number of non-zero entries in the $j$-th column. Suppose ... top of the stack contains the value $max_{1\leq i \leq 30} r_i$. Write pseudo-code for creating such a stack using a single scan of the matrix $A$.
1 vote
5
Let $A$ be a $30 \times 40$ matrix having $500$ non-zero entries. For $1 \leq i \leq 30$, let $r_i$ be the number of non-zero entries in the $i$-th row, and for $1 \leq j \leq 40$, let $m_j$ be the number of non-zero entries in the $j$-th column. Show that there is a k such that $1 \leq k \leq 30$, $r_k \geq 17$ and there is an $l$ such that $1 \leq l \leq 40$, $m_l \leq 12$.
1 vote
Let $x, y$ be two non-negative integers $< 2^{32}$. By $x \wedge y$ we mean the integer represented by the bitwise logical $AND$ of the 32- bit binary representations of $x$ and $y$. For example, if $x = 13$ and $y = 6$, then $x \wedge y$ ... of the pseudo-code for the input $x = 13$? What will be the output of the pseudo-code for an arbitrary non-negative integer $x < 2^{32}$?
Let $x=(x_1, x_2, \dots x_n) \in \{0,1\}^n$ By $H(x)$ we mean the number of 1's in $(x_1, x_2, \dots x_n)$. Prove that $H(x) = \frac{1}{2} (n-\Sigma^n_{i=1} (-1)^{x_i})$.
How many asterisks $(*)$ in terms of $k$ will be printed by the following C function, when called as $\text{count}(m)$ where $m = 3^k \ ?$ Justify your answer. Assume that $4$ bytes are used to store an integer in C and $k$ is such that $3^k$ can be stored in $4$ bytes. void count(int n){ printf("*"); if(n>1){ count(n/3); count(n/3); count(n/3); } }