December 2012
Paper 2
Paper 3
December 2014
December 2015
July 2016
JUNE 2013
June 2015
|
51: |
Suppose there are logn sorted lists of n logn elements each. The time complexity of producing a sorted list of all these elements is (use heap data structure)
|
A.
|
O (n log logn)
|
B.
|
θ(n logn)
|
C.
|
Ω(n logn)
|
D.
|
Ω(n3/2)
|
|
|
Answer
Report
Discuss
Option: A Explanation :
first of all built a heap by selecting one element from each of logn lists , comlexity of doing this will be O(logn) (as we hav logn element)
now we will have two minimum elements from the previously built heap and and insert into a new heap
complexity of doing this will be 2log(logn)+log(logn) =3log(logn)
for n elements = O(n log(logn))
so resultant complexity will be nlog(logn)+logn
i.e. O(nlog(logn)) (as logn is really small value so that is ignored)
|
52: |
Consider the program below in a hypothetical programming language which allows global variables and a choice of static or dynamic scoping
int i;
program Main( )
{
i = 10;
call f ( );
}
procedure f( )
{
int i = 20;
call g ( );
}
procedure g( )
{
print i;
}
Let x be the value printed under static scoping and y be the value printed under dynamic scoping. Then x and y
are
|
A.
|
x = 10, y = 20
|
B.
|
x = 20, y = 10
|
C.
|
x = 20, y = 20
|
D.
|
x = 10, y = 10
|
|
|
Answer
Report
Discuss
Option: D
Explanation :
|
53: |
If the parse tree of a word w generated by a Chomsky normal form grammar has no path of length greater than i, then the word w is of length
|
A.
|
no greater than 2i+1
|
B.
|
no greater than 2i
|
C.
|
no greater than 2i–1
|
D.
|
no greater than i
|
|
|
Answer
Report
Discuss
Option: C
Explanation :
|
|