Вы находитесь на странице: 1из 9

COMPILER DESIGN

Q1. Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar? a) Removing Left recursion alone c) Removing left recursion & left factoring the grammar b) Factoring the grammar alone d) none of these

Q2. Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states. The relationship between n1 and n2 isa) n1 is necessarily less than n2 c) n1 is necessarily greater than n2 Q3- Consider the grammar shown belowSiEtSS| SeS| Eb In the predictive parse table M of this grammar, the entries M[S, ] and M[S, $ ] respectively area) {SeS} and {S } c) {S } and {S } Q4-Consider the following C code segmentfor(i=0; i<N; i++) { for(j=0; j<N; j++) { if(I%2) { x=x+(4*j+ 5*i); y=y+(7+ 4*j ); } } } Which one of the following is false? b) {SeS} and { } d) {SeS, S } and {S } b) n1 is necessarily equal to n2 d) None of the above

a) The code contains loop-in variant computation b) There is scope of common sub-expression elimination in this code c) There is scope of dead code (Unreachable code) elimination in this code d) There is no scope of loop jamming in this code Q5- Which one of the following is a top-down parser? a) Recursive descent parser c) An LR (k) parser b) Operator precedence parser d) An LALR (k) parser

Q6-Consider the following CFG with {S,A,B} as non-terminals and {a,b} as terminals. S is the start symbol. Aa BaB AaS Bb AbAA BaBB Which of the following string is generated by the grammar? a) aaaabb b) aabbbb c) aabbab d) abbbba SbA S aB

Q7- For the correct answer string of Q6 how many derivation trees are there? a) 1 b) 2 c) 3 d) 4

Q8- Some of the code optimization are carried out on the intermediate code becausea) They enhance the portability of the compiler to other target processor b) Program analysis is more accurate on intermediate code than on machine code c) The information from data flow analysis cannot otherwise be used for optimization d) The information from the front end cannot otherwise be used for optimization Q9- Which data structure in a compiler is used for managing information about variables and their attributes? a) Abstract syntax tree b) Semantic stack c) Parse table d) Symbol table

Q10- In C Compiler, the word Struct is recognized duringa) Parsing of the program c) The lexical analysis of program b) The code generation d) Data flow analysis

Q11- Consider the grammar G={S(L)S | a , LL, S | S } After removing left recursion, we geta) {S(L) S| a , LSA , ASA| } b) {S(L) S| a , LSA , ASA } c) {S(L)S | a , LSA , A,SS| } d) {S(L)S | a , LSA , ASS| }

Q12-Consider the following augmented grammarS S S DD DeD | d If I is the set of item {[SS, $]}, then the CLOSURE (I) contains LR (1) items a) b) c) d) {[ S DD , $], [ C dD , e] , [C d , e/d]} {[ S DD , $], [ C dD , e/d] , [C d , e]} {[ S DD , $], [ C dD , $] , [C d , $]} {[ S DD , $], [ C dD , e/d] , [C d , e/d]}

Q13-Consider the following CFGS aAbB | bAaB | A S B S a) FIRST(A)={a,b, } =FIRST(B) FOLLOW(A)={a,b} FOLLOW(B)={a,b,$} c) FIRST(A)={a,b, $ } FOLLOW(A)={a,b} FOLLOW(B)={$} FIRST(B)={a,b, } d) FIRST(A)={a,b }=FIRST(B)\ FOLLOW(A)={a,b} FOLLOW(B)={a,b}

b) FIRST(A)={a,b, } =FIRST(B) FOLLOW(A)={a,b} FOLLOW(B)=

OPERATING SYSTEM Q14-Two processes, P1 and P2, needs to access their critical section code. Consider the following synchronization construct used by the processes, S1 & S2 are the shared Boolean variable, the initial value of S1 & S2 are randomly assigned. Process P1 While(true) { While(S1==S2) { Critical Section Code S1=S2; } } Process P2 While(true) { While(S1!=S2) { Critical Section Code S1=!(S2); } }

Which one of the following statements describe the property achieved? a) Mutual exclusion but not progress b) Progress but not mutual exclusion c) Neither mutual exclusion nor progress d) Both Mutual exclusion and progress

Q15- In the following process state transition diagram for a uniprocessor system assumes that there are always some processes in the ready state:

Now consider the following statements: I. If a process makes a transition D, it would result in another process making transition A immediately. II. A process P2 in blocked state can make transition E while another process P1 is in running state. III. The OS uses preemptive scheduling.

IV. The OS uses non-preemptive scheduling. Which of the above statements are TRUE? a) I and II b) II and III c) I and III d) II and IV

Q16-A process executes the following codefor(i=0;i<n;i++) fork(); The total number of child processes created is a) n b) 2n c) 2n d) 2n+1 1

Q17. Assume following jobs are to be executed on single processor system. Process Id CPU Burst Time P 4 Q 1 R 8 S 1 T 2 The processes are assumed to have arrived at time 0 and in the order P, Q, R, S, T. The departure time (completion time) for job P if scheduling is round robin with time slice 1. a) 4 b) 10 c) 11 d) 12

Linked Answer Questions (Q5 & Q6):

Assume that you have a page-reference string for a process with m frames (initially all empty). The page-reference string has length p, n distinct page numbers occur in it. Answer these questions for any page replacement algorithms.

Q18-What is a lower bound on the number of page faults? a) n b) m c) p d) None

Q19- What is an upper bound on the number of page faults?

a) n

b) m

c) p

d) None

Q20-Consider the following C program#include <stdio.h> #include <unistd.h> int main(void) { printf("Hello"); fork( ); printf("I am after forking"); } Which process will never print Hello -? a) Child process b) Parent process c) Both parent & child d) None

Q21-Consider the following set of processesProcess P1 P2 P3 P4 Arrival Time 0 1 2 4 Burst Time 5 3 3 1

What is the average turnaround time for these processes with preemptive shortest remaining processing time first (SRPT) algorithm? a) 5.50 b) 5.75 c) 6.00 d) 6.25 e) Other Value

Q22-A process has been allocated 3 page frames. Assume that none of the pages of the process are available in the memory initially. The process makes the following sequence of page references1,2,1,3,7,4,5,6,3,1 If optimal page replacement policy is used, how many page faults occur for the above reference string?

a) 10

b) 9

c) 8

d) 7

Q23- Least recently used (LRU) page replacement policy is a practical approximation to optimal page replacement. For the above reference string, how many more page faults occur with LRU than optimal page replacement policy? a) 0 b) 1 c) 2 Q24- Which of the following statement are trued) 3

I. Shortest remaining time first scheduling may cause starvation. II. Preemptive scheduling may cause starvation III. Round robin scheduling is better than FCFS in terms of response time. a) I only b) I & III Only c) II & III only d) I, II & III

Q25- A computer handles several interrupts sources of which the following are relevant for this question. Which one of the following will be handled at the highest priority? a) Interrupt from CPU temperature sensor (raised interrupt if CPU temperature is too high) b) Interrupt from mouse(raised interrupt if the mouse is moved or button is pressed) c) Interrupt from keyboard (raised interrupt when key is pressed or release) d) Interrupt from hard disk(raised interrupt when a disk read is completed) Q26- Consider the following set of processesProcess P1 P2 P3 Arrival Time 0 1 3 Burst Time 5 7 4

The completion order of the three processes under the policies FCFS and RR2 (Round Robin scheduling with CPU quantum of 2 time units) area) FCFS: P1,P2,P3 RR2: P1,P2,P3 b) FCFS: P1,P2,P3 RR2: P1,P3,P2 c) FCFS: P1,P3,P2 d) FCFS: P1,P2,P3 RR2: P1,P3,P2 RR2: P3,P1,P2

Q27. Consider the virtual page reference string- 1, 2, 3, 2, 4, 1, 3, 2, 4, 1 On a demand paged virtual memory system running on a computer system that

has main memory size of 3 page frames which are initially empty. Let LRU, FIFO and Optimal denote the number of page fault under the corresponding page replacement policy. Thena) OPTIMAL<LRU<FIFO c) OPTIMAL =LRU b) OPTIMAL<FIFO<LRU d) OPTIMAL=FIFO

Answer Keys Compiler Design Operating System c a 1 14 b b 2 15 d b 3 16 c c 4 17 a a 5 18 c c 6 19 b a 7 20 b a 8 21 d d 9 22 c c 10 23 c d 11 24 d a 12 25 a d 13 26 d 27

Q.28-If A+B+C = , then

(a) sinA

(b)

sinB

(c) sinC

(d)

Q.29-Find the value of

for which the following system of equations

x + y + 4z = 1, x+2y-2z = 1 x + y + z = 1 will have a unique solution (a)

Q.30 The characteristic roots of a Hermitian matrix are: (a) all real (b) all imaginary (c) some real and some imaginary (d) None of these

Вам также может понравиться