Computer Software MA30007 PDF
Computer Software MA30007 PDF
Instruction: There are 16 questions on 2 printed sides. Every question carries 5 marks.
Use of calculators is not permitted. Rough work involved in the question must be shown. However
final answer should be written in a box. If a question has more than one possible answer then any one
of them should be written unless you are instructed to do otherwise. If you are asked to write all
answers then write all of them in the same box. Rough work must be shown along with the answer.
·No rough work should be done on the question paper. On the question nothing other than the name
and the roll number should be written.
Rough work must be shown along with the answer. Only answer will carry 0 marks.
In case of any doubt or mistake any query should not be made. In case of wrong question full marks
will be awarded later.
1. We want to multiply polynomials (129-73x) and (-147+68x). We are not supposed to multiply two
three digit null)bers. What multiplications are needed?
[Hint: Two ofthe multiplications are 129*68 and (-73)*68. Write remf!ining two multiplications?]
3. U:t 'x' be a random integer. Let y=((x mod 1000) mod I4). What is the probability that y=O? Write
answer correct to 5 places of decimal. (0.021468 should be written as 0.02146][0.0237 should be
written as 0.02370][Do not use calculator]
For (i= I to 568) print(A)
4. Let buffer size be 100. How many A's are printed by the given sleep(5)
program at time t=5? for(i=l to IIO)print(A)
How many A's will be printed at time t=5 if fflush(stdout) is fflush( stdout)
removed!? (buffer size= I 00) for (i= I to I 566) print( A)
[Hint: 500 A's are printed at time t=O.] sleep(70)
5. Let an integer be represented as it is. Let a float number (x) is represented as (int)(x/30+2.74). What
will be the output of following program on input 588? [Example: Input 235 output 217]
int a; float b; scanf("%d",&a); b=a; a=b; printf("%d",a);
7. A dynamic set (S) is implemented using priority queue (P). An element is put in (S) by putting in (P)
[Put(S,x)=Put(P,x)]. To take an element from dynamic set an empty priority queue (R) is taken.
After that following operations are done. Take(S,x) is equivalent to following:
do{y=take(P); if(y :;t: x)Put(R,y);}while(y :;t: x); while(R not empty){y=take(R); put(P,y);}
Let a dynamic set be {I 3, 34, 57, 76, 28, 65}. From it element 34 is taken. What are elements of R
after the complementation of do{ ... }while(y :;t: x)? [Definition: biggest element is taken from priority
queue. a=take(Q) means 'a' is the biggest element of (Q). Remove it]
8. Let 'a' and 'b' be sorted arrays. Search range to find 4201h element is [158,363] assuming it is in
array 'a'. What will be the search range assuming it is in array 'b'?
[Example: Let sizes of 'a' and 'b' are 10 and 20 respectively. To find I ih element of the system
assuming it is in 'a' the search range is [I, I0]. Assuming it is in 'b' the search range will be [2, 12]]
P.T.O.
9. What is smallest possible positive integer 'a' so that output of given .program' is "ram". Assume that
float has 24 significant bits.
int a;double x;float y; x=a+47.1; y=x; if (y>x) printf("ram"); if (y<x) printf("hari");
I 0. A list has 3 distinct elements 42, 11, 33. These elements are repeated 385, 436 and 567 times
respectively. How many nodes are needed in the representation of the list?
Example: Let a list has 4 distinct elements II, 17, 26 and 18. These elements, ~re repeated I, 3, 2 and
1 time respectively. We need I 0 nodes in the representation of such a list
Example: ( 11,17 ,26, 17,17 ,26, 18). Its representation is following First: I I
Data 26 18 ·11 -62 62 81 17 --9-0----.--8-l-,..---...--9-0----,
Next -81 0 17 -90 26 18 -62
~--~~-+----4---~
IS 17 17 26
[Reason: The list is (II, 17,26,-81 ,-62,-90, 18) Here 62 is 17 81 is 17.90 is 26.]
12. A person wants to find the sum of 100 numbers except the maximum and second-maximum. After
1
operating on first 67 numbers the values of a= I 0000 b=;=80 12 and c=7222. Let 68 h number be 1312.
1
What will be the values of a, b and c after operating on 68 h number?
'[Notation: a: sum of all; b: sum except max; c:sum except max and second-max]
13. A program is written to find 5241h last I OK.t4 number before 467th last I OK +6 number. What is
missing(s) in following? (Hint: In sequence 84, 14, 15, 24, 26, 94, 36, 34, 44, 46; 29 the 3rd last
I OK+4 number before 2nd last I OK +6 number is 14.]
For(i=l ton)
{ x=input
lf(x mod 10=4) {pl=p2; p2=p3; .......... ; p998=p999; p999=p1000; p1000=missingl; }
If (x mod 10=6) {ql =q2; q2=q3; .......... ; q998=q999; q999=q 1000; q 1OOO=missing2; }
}
Print( missing~)
'··-·
14. Express 2324 as' sum of elements ofthe sequence 3, 27, 154, 184,224,227,540, 1889 such that
there are exactly two even numbers. (Example: Express 905 when exactly three even numbers.
answer 154+27+ 184+540] [Hint: Subtract 140 from even numbers and then show method]
15. We want to define function f(x,y) using tail call. The value mput a,b
returned by the function is same as the output of the p=a+b q=a*b+83
following program on input a=x and' b=y. What is missing? while (p<q)
f(a,b )=g(missing). { p=p+(p div 2) q=q+b }
g(a,b,p,q)=g(a,b,p+(p div 2),q+b) ifp<q r=fH1
g(a,b,p,q)=(JHI)*a ifp~q print r*a