Sei sulla pagina 1di 10

## (Date of Birth): ___________________________________________________ : (Phone): (E-mail): ___________________________________________________ ___________________________________________________

(Instructions):
. Bangla or English.) . . . , , (The answers should be as brief as possible.) (Topics mentioned (You can answer either in

under Required knowledge are described at the end of the question paper.) (For general solutions Mathematical formula, step by description or programming code - anything is acceptable.) . marks.) , (Partial (Number of questions is 10. Each question carries 20 answers will also be evaluated, so we encourage you to answer as much as you can.)

1
Question 1: N i) ii) iii) iv) Question 2: (Required Knowledge): (Binary Numbers) B V 0 1) V V V 0 X (X (You are given a binary , , , N ? (You are given an even number N, Find the summation of all even numbers between 1 and N) (Write the general formula)  N=10 (Find the summation when N=10)  N=100 (Find the summation when N=100)  N=2000000000 (Find the summation when N=2000000000) 

number B and a value V. At the beginning V is 0. Starting from left to right for every digit of the binary number you will change that value of V. Suppose the next digit is X ( X is obviously 0 or 1).You will change V in the following process)

V of V) 0 0 1 1 2 2

(Previous Value

(Value of X)

(New Value of V)

0 1 0 1 0 1 B=110 ) ) ) V 1. 0 0 1 V=1 V=0 V=0 V=0 X=1, X=0, X=1 , V=0 V=0

0 1 2 0 1 2

V=1

2
(Suppose B=110.Then at the beginning V=0; 1) Leftmost digit is 1. As X=1 and V=0 , so now V=1. 2) Next digit is 1.As X=1 and V=1 , now V will be 0 3) Next digit is 0. As X=0 and V=0 , now V will be 0. So final value of V is 0.) i) B V (Propose a general

method to find the final value of V for any binary number B)  ii) V iii) V iv) V B B 1234 B 123456789101112 10110001110010 (Find V when B is the binary (Find V when B is the Binary representation of (Find V when B is the Binary

number 10110001110010)  the decimal number 1234)  representation of the decimal number 123456789101112)  Question 3: 0 N 1 1 0 , 0011, 0, 1, 110, 1010, 1111 ? (A bit string consists of only 0

and 1. For example, 0011, 0, 1, 110, 1010, 1111 are some b it strings. How many bit strings of length N has more 1s than 0s?) i) N=3 ii) N=10 iii) N=500 iv) N Question 4: (Required Knowledge): (Tree) , (You are given a rooted tree with N nodes. You are currently in the root. You want to visit all the nodes of the tree at least once. You need one second to go from one node to an adjacent node) N ? (How many string is there for N=3?)  ? (How many string is there for N=10?)  ? (How many string is there for N=500?)  (Propose a general solution of N length bit string) 

i) , ? N (How much

time do you need, if you have to go back to the root in minimum amount of time after visiting all the nodes? Total number of node including root is N)  ii) , ? N (Find the Figure Q4(iii)

minimum possible time you need if you stop right after visiting all the nodes. Total number of node including root is N) 

iii)

(i)

(ii)

(Find the time for cases (i) and (ii) for the tree in figure) 

Question 5:: (Required Knowledge): / (Stack/Queue) popS popQ [2,1] [2,1] [1,2,5] popQ [2,5] pushQ(X) , pushS(3) pushS(1) pushS(X) X X pushS(2) [3,2,1] popS

## , pushQ(1), pushQ(2), pushQ(5) , (You are given a stack and a

queue. Given functions are pushS(X) which pushes the value X in top of the stack, popS which pops the value from stack top, pushQ(x) which pushes the value X in back of the queue and popQ which pops the value in front of the queue. For example, if we execute pushS(1) and pushS(2) the stack will look like [2,1] from top to bottom. And then if we pushS(3) then the stack becomes [3,2,1]. After a popS it becomes [2,1]. Similarly for pushQ(1), pushQ(2) and pushQ(5) the queue looks like [1,2,5] from front to back. After a popQ it becomes [2,5]. Now given a set of instructions executed one after one, write the condition of the stack and queue after executing each instructions. the first two is done for your convenience) 

4
i) pushS(1) Answer: ,[] ii) pushS(2) Answer: [2,1],[] iii) pushQ(5) iv) popS v) popQ vi) pushQ(10) vii) pushS(3) viii) pushQ(20) ix) pushS(popQ) x) popS xi) popS xii) popQ Question 6: (Required Knowledge): / (Stack/Queue) reverse(k) , [1,3,5,4,6], reverse(3) reverse(3), reverse(4), reverse(3) reverse(2) [1,3,4,5,6] k [5,3,1,4,6]. [1,3,5,4,6]

(You are given a stack and a operation reverse(k) which reverses the order of the top k element of the stack. For example, if a stack is [1,3,5,4,6], after reverse(3) it becomes [5,3,1,4,6]. Using only this operation sort a stack from lowest to highest value. For the stack [1,3,5,4,6] in example we can perform reverse(3), reverse(4), reverse(3) and reverse(2) to get [1,3,4,5,6]. Try to do this using minimal number of operations.) i) ii) Question 7: (Required Knowledge): (Recurrence Relation) i) b(n) (Find of the value of b(n))  [1,7,5,2,4,3,6] (Write the operation sequence for the stack (Write the general steps to solve the problem) 

[1,7,5,2,4,3,6]) 

ii) a(n)

## (Find of the value of a(n))  (The definition of

a(n) = a(n-1) + 7b(n - 2) where a(0) = 2, n >= 0 [b(n) b(n) is mentioned in question i)] 1 n=3 2 n = 10 iii) F(n,k) (Find of the value of F(n,k)) 

## Question 8: (Required Knowledge): (Recurrence Relation) n 3 ?

(How many n-digit numbers are there, where the sum of every adjacent digit is less than or equal to 3?) n=3 30 (Example: For n = 3, there can be 30 such numbers.)

[000, 001, 002, 003, 010, 011, 012, 020, 021, 030, 100, 101, 102, 103, 110, 111,112, 120, 121, 200, 201, 202, 203, 210, 211, 212, 300, 301, 302, 303] i) n = 4 ii) n = 7 iii) Question 9:: n x (Find the result for n = 4.)  (Find the result for n = 7.)  (Find a recursive solution of the problem.) 

1 x 5 5 1*2=2 5 1

2 5 2

1 (1 5)

6
1, 2, 3 12 1,2 12 , 1 2  (Professor K invented a process to find how many factors (divisors) are there of a number n. The process is: Find out the number of positive integers between 1 and the square root of n, which are factors of n. Let this value to be x. The answer is twice the value of x 1 100 3*2=6 12 ?  6 12)

12

12

3 (1, 2, 3, 4, 6

For example: For n = 5, Only 1 and 2 is less than the square root of 5. Of them only 1 divides 5. So according to the process of professor K the number of factors is 1*2 = 2. 5 has 2 divisors (1 and 2) For n = 12, Only 1, 2 and 3 are less than the square root of 12. Of them 1, 2 and 3 divides 12. So according to the process of professor K the number of factors is 3*2 = 6. 12 has 6 divisors (1, 2, 3, 4, 6, 12) Do you think professor Ks process is correct? 1 If not, show an example for which the process will fail.  2 For how many numbers between 1 and 100 this process will fail?) 

Question 10:: n k m

PP.P( PP..

P 

## ii) n = 5, k = 3, m = 2  iii) n = 1000000000, k = 30, m = 25 

7
(n pigeonholes are kept side by side in a row. You want to put pigeons in some of the holes in a way that for every k consecutive holes there will be exactly m holes with a pigeon. There shouldnt be more than one pigeon in a hole. For example: For n = 4, k = 3, m = 2, a solution can be PP.P(Here P means a pigeon and . means a hole). But .PPP, PPP., P.P. or PP.. arent solutions. i) Write a general formula to find the number of solutions for n, m and k.  ii) n = 5, k = 3, m = 2  iii) n = 1000000000, k = 30, m = 25 

## (Appendix) (Recurrence Relation)

, (In mathematics, a recurrence relation is an equation which defines a sequence where one or more initial terms are given and each further term of the sequence is defined as a function of the preceding terms.) , T(n) = 2T(n-1) + 1, T(0) = 0 (Building a table of values yields the following) n T(n) 0 0 1 1 2 3
n

3 7

4 15

5 31

6 63

7 127

T(n)
n

2 -1

## (We might conjecture that that the

value of T(n) is 2 -1 which is true. You can prove it using mathematical induction. One well known recurrence relation is the Fibonacci sequence.) (Binary Numbers) 0

8
(Its possible to uniquely express any number as a sum of one or more power(s) of two. We can express the number as a sum of each used powers of two multiplied by 1 and each unused powers multiplied by 0. Youll get a better idea from the following example) 11 = 8 + 2 + 1 =1 * 2^3 + 0 * 2^2 + 1 * 2^1 + 1 * 2^0 = 1011 in Binary

0 0 (Binary)

1 1

2 10

3 11

4 100

5 101

6 110

7 111

8 1000

9 1001

10 1010

Push

## (Stack can be compared with a pile of books. If we want

to put a new book in the pile we put the book on the top and if we remove one we remove from the top too. Here putting something is called Push and removing is called pop. For example, if we have a stack [1,2] where 1 is the topmost item. If you pop we will get 1 and the stack becomes . After Push(3) the stack becomes [3,2]. Thats why stacks operation is called Last in first out) (Queue) Push [1, 2] [2,3] 1 Pop Pop 1  Push(3) (Queue can be compared

with a line in front of a bus counter where a new person stand in the back of the line and the ticket is given to the person in the front of the line. Here standing in the back is called Push and giving ticket to the front person is called Pop. For Example, we have a queue [1,2] where 1 is the front item. If we Pop we will get 1 and the queue becomes . If we Push(3) then the queue becomes [2,3]. This nature of queue is called First in first out)

(Node):

(A point or object. In the figure, there are ten nodes.) (Edge): (The relationship between two nodes. It is represented as a line between two nodes. These node are considered to be adjacent to each other. For example, in the figure. 4 and 9 are adjacent to 3. 4 and 7 are adjacent to 6.) (Root): (Predecessor): , (The idea (A special node. Here 3 is the root.)

of predecessor is best explained from the figure. Here node 4 is the predecessor to 10, 5 and 6. Root does not have any predecessor.) (Tree): n n-1 (Collection of nodes and edges such that every node other than the root has exactly one predecessor. A tree with n node has exactly n-1 edges.)