Q1. A new language has 15 possible letters, 8 different kinds of punctuation marks – and a blank character. Rahul wants to create two data types, first one which could store the letters of the language and a second one which could store any character in the language. The number of bits required to store these two data-types will
respectively be:
A. 3 and 4
B. 4 and 3
C. 4 and 5
D. 3 and 5
Ans. C
Q2. A code takes the following code steps (equivalently time unit) to execute:
5n3 + 6n2 + 1. Which of the following is not true about the time complexity of the program?
A. It has a time complexity of O(n3)
B. It has a time complexity of O(n4)
C. It has a time complexity of O(n2)
D. It has a time complexity of THETA(n3)
Ans. C
Q3. We have two programs. We know that the first has a time complexity O(n2), while the second has a complexity &omega(n2).
For sufficiently large n, which of the following cannot be true?
A. Both codes have same complexity
B. The first code has higher time complexity than the second
C. The second code has lower time complexity than the first code.
D. Both codes are the same.
Ans. B
Q4. Parul takes as input two numbers: a and b. a and b can take integer values between 0 and 255. She stores a, b and c as 1-byte data type. She writes the
following code statement to process a and b and put the result in c.
c = a + 2*b
To her surprise her program gives the right output with some input values of a and b, while gives an erroneous answer for others. For which of the following inputs will it give a wrong answer?
A. a = 10 b = 200
B. a = 200 b = 10
C. a = 50 b = 100
D. a = 100 b = 50
Ans. A
Q5. Prashant takes as input 2 integer numbers, a and b, whose value can be
between 0 and 127. He stores them as 7 bit numbers. He writes the following code to process these numbers to produce a third number c.
c = a – b
In how many minimum bits should Prashant store c?
A. 6 bits
B. 7 bits
C. 8 bits
D. 9 bits
Ans. C
