0% found this document useful (0 votes)
320 views

MSQ Questions From Each Subject

The document contains summaries of questions related to various computer science topics such as automata theory, programming languages, algorithms, databases, and operating systems. Key points discussed include: - Whether certain languages consisting of palindrome strings over an alphabet would be regular or not, depending on the structure of the original language. - Precedence rules and ambiguity in context-free grammars. - Valid implementations of a stack using an array and position pointer. - Properties that must be true about vertices in a finite directed acyclic graph. - Differences between direct-mapped and associative caches and factors affecting cache miss rates. - Why merge sort has a time complexity of O(n log

Uploaded by

sunilsinghm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
320 views

MSQ Questions From Each Subject

The document contains summaries of questions related to various computer science topics such as automata theory, programming languages, algorithms, databases, and operating systems. Key points discussed include: - Whether certain languages consisting of palindrome strings over an alphabet would be regular or not, depending on the structure of the original language. - Precedence rules and ambiguity in context-free grammars. - Valid implementations of a stack using an array and position pointer. - Properties that must be true about vertices in a finite directed acyclic graph. - Differences between direct-mapped and associative caches and factors affecting cache miss rates. - Why merge sort has a time complexity of O(n log

Uploaded by

sunilsinghm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

TOC :

Q1:
If L is a regular language over alphabet {a,b}, let L’ be the set of strings
in L that are palindromes.
Which of the following statement is false ?
A. L’ can never be regular.
B. L’ is always regular.
C. If L is infinite regular language then L’ is Never regular.
D. If L is set of all strings over the given alphabet then L’ is non-
regular.

Answer : A,B,C
Explanation : If L is finite then L’ is also finite so L’ can be regular. So,
option A is false. If L is set of all strings over the given alphabet then L’
is non-regular. So option B is false. Option D is true. Option C is false
for the language a*.

Compiler Design :
Q2:
Choose the False statements about the above grammar and language :
A. The given grammar is ambiguous.
B. “and” has higher precedence than “or”
C. “or” has higher precedence than “and”
D. “or”, “and” are left associative, But not right associative

Answer : B,C,D
Explanation : “or, and” are both left and right associative and have
equal precedence. The grammar is ambiguous because “p or q or r” has
more than one parse trees.

C and DS :
Q3:

A stack can be implemented with an array A[0,..,n-1], and a variable


pos. The push and pop operations are defined by the following code :

push (x)

A[pos] ← x

pos ← pos + 1
end push

pop ( )

pos ← pos - 1

return A[pos]

end pop

For this implementation, pos = 0, gives the correct initialization for


this stack implementation.

If it is assumed that suitable changes in the initialization code were


also made, which of the following changes to Push and Pop would yield
a correct implementation of stacks?

A. Replacing the code for Push with that for Pop and vice versa

B. Making Push decrement pos and Pop increment pos

C. Reversing the order of the statements in both Push and Pop

D. None

Answer : B,C
Explanation :

I. Replacing the code for Push with that for Pop and vice versa

This is false because push and pop will work opposite of what they
should do. Push will do popping and pop will do pushing.

II. Making Push decrement pos and Pop increment pos


If we make the initialization condition “pos = N-1” then this
modification will work just fine.

III. Reversing the order of the statements in both Push and Pop

If we make the initialization condition “pos = -1” then this modification


will work just fine.

Disc Maths :
Q4:
Let G = (V,E ) be a finite directed acyclic graph with |E| > 0. Which of
the following must be true?
A. G has a vertex with no incoming edge.
B. G has a vertex with no outgoing edge.
C. G has an isolated vertex, that is, one with neither an incoming edge
nor an outgoing edge.
D. None

Answer : A,B
Explanation : Since graph is finite directed acyclic graph so there must
be some vertex with no incoming edge and there must be some vertex
with no outgoing edge. C is not necessarily true.

CO :
Q5:
Which of the following statements about caches is (are) true?

A. A direct-mapped cache can have a lower miss rate than an associative cache of the same
size (number of blocks).
B. Programs with high spatial locality have a low cache miss rate primarily because the exact
same addresses are re-referenced.
C. Programs with high temporal locality have a low cache miss rate primarily because the exact
same addresses are re-referenced.
D. None

Answer : A,C
Explanation :
Direct-mapped cache may have lower miss rate than an associative
cache of the same size (number of blocks) because in case of
associative cache, page replacement depends on the page replacement
algorithm, But in case of direct mapped cache, page replacement
algorithms are Not used.

So, consider there are four cache lines, and the following reference
string( requested block numbers of main memory) : 0,1,2,3,4,3,4,3,4,3 ..

Assume associative cache uses "Most-recently used" page replacement


policy. Then direct mapped cache will have lower miss rate than
associative cache.

2. There are two basic types of reference locality – temporal and


spatial locality. Temporal locality refers to the reuse of specific data,
and/or resources, within a relatively small time duration. Spatial
locality (also termed data locality) refers to the use of data elements
within relatively close storage locations.

Temporal locality: Recently referenced items are likely to be


referenced in the near future.

Spatial locality: Items with nearby addresses tend to be referenced


close together in time.
So, 1 and 3 are true.

Algo :
Q6:
Mergesort works by splitting a list of n numbers in half, sorting each
half recursively, and merging the two halves.
Which of the following data structures will allow mergesort to work in
On O(nlogn) time?
A. A singly linked list
B. A doubly linked list
C. An unsorted array
D. A sorted array

Answer : A,B,C,D
Explanation :
Using array, sorted or unsorted, we already know that merge sort
works in nlogn time. Using linked list also it will work in nlogn time. In
linked list we will do these things in merge sort :
1. Finding middle of the list (O(n) time)
2. Sorting both halves (2T(n/2) times)
3. Merging the two sorted halves (O(n) time)

So, we have T(n) = 2T(n/2) + O(n)+O(n)


T(n) = 2T(n/2) + O(n)
So, nlogn.
DBMS :
Q7:
The lost update anomaly is said to occur if a transaction reads a data item , then another
transaction writes that data item (possibly based on a previous read), after which writes
the data item . The update performed by has been lost, since the update done by ignored
the value written by .

Which of the above statements is/are true?

A. Lost update problem may exist in Strict recoverable schedules.

B. Lost update problem may exist in Conflict serializable schedules.

C. Lost update problem may exist in view serializable schedules.

D. None

Answer : A,C
Explanation :
In Serializable schedules (Conflict Serializable), We DO NOT have lost update problem
because when there is lost update problem, there will be cycle in the precedence graph,
So Not Conflict serializable.

You might also like