Q3.Let A and B be infinite alphabets and let # be a symbol outside both A and B. Let f be a total
functional from A*
to B*
. We say f is computable if there exists a Turning machine M which
given an input x in A*
, always halts with f(x) on its tape. Let Lf denote the language
{x#f(x)|x∈A*}. Which of the following statements is true:
Answer : Option AExplaination / Solution:
A TM is recursive iff it halts for every input string (either in accept or reject state).
Here, a computable function is defined in a similar way.
Assuming that m and n point to valid NULL- terminated linked lists, invocation of join will
Answer : Option BExplaination / Solution:
While loop in Join Procedure moves the pointer ‘p’ to the last node of the list “n”. And at the
last statement, we are initializing the next of the last node of list n to start of list “m”.
But in some cases it may dereference to null pointer.
The code suffers from which one of the following problems:
Answer : Option DExplaination / Solution:
(A) is wrong. We don’t need to cast the result as void * is automatically and safely promoted
to any other pointer type in this case.
(B) It is discarded for obvious reason.
(C) is wrong, because dangling pointer is nothing but the pointer which is pointing to non-
existing memory (deallocated or deleted memory) which is not happening here.
(D) is the answer. When you are calling malloc second time, new location is assigned to x
and previous memory location is lost and now we don’t have no reference to that location
resulting in memory leak.
Q10.Recall that Belady’s anomaly is that the pages-fault rate may increase as the number of
allocated frames increases. Now consider the following statements:
S1: Random page replacement algorithm (where a page chosen at random is replaced)
suffers from Belady’s anomaly
S2: LRU page replacement algorithm suffers from Belady’s anomaly
Which of the following is CORRECT ?
Answer : Option BExplaination / Solution:
Statement 1 is “TRUE”. Because there can be a case when page selected to be replaced is by
FIFO policy.
Statement 2 is “FALSE”. Because LRU page replacement algorithm does not suffers
from Belady’s Anomaly. Only FIFO page replacement algorithm suffers from Belady’s
Anomaly.
Total Question/Mark :
Scored Mark :
Mark for Correct Answer : 1
Mark for Wrong Answer : -0.5
Mark for Left Answer : 0