Compiler Design MCQs

Compiler Design MCQs

The following Compiler Design MCQs have been compiled by our experts through research, in order to test your knowledge of the subject of Compiler Design. We encourage you to answer these 40 multiple-choice questions to assess your proficiency.
Please continue by scrolling down.

1: Which of the following is NOT a characteristic of a greedy algorithm?

A.   A greedy algorithm always gives an optimal problem solution.

B.   A greedy algorithm can be recursive.

C.   A greedy algorithm can be iterative.

D.   A greedy algorithm can be used with graph data structures.

A.   Breadth-first search algorithm

B.   Fast Fourier transform algorithm

C.   Dijkstra's algorithm

D.   Prim's algorithm

3: Is it possible to multiply two matrices with dimensions 4*6 for the first matrix and 8*10 for the second matrix?

A.   It is always possible.

B.   It is always impossible.

C.   It is possible only in complex analysis but not in real domain.

D.   It is possible only the determinant of first matrix is non-zero.

4: Is garbage collection available in Common Lisp implementations?

A.   No, it isn't.

B.   Yes, but only in SBCL.

C.   Yes, in all implementations.

D.   Yes, except in CMUCL.

5: What is the return value of the subtype "predicate", in case it CANNOT decide what is the relation between types it is asked about?

A.   It will raise an exception

B.   It will return nil

C.   It will return (nil nil)

D.   It will return (nil nil t)

6: Which of the following problems prevents garbage collectors from being used in the real-time systems?

A.   They involve huge memory fragmentation.

B.   They can not be thread-safe.

C.   They can make real-time systems hang for some period of time.

D.   All of the above

7: What is the advantage of using a suballocator in a memory management system?

A.   It allows to have memory chunks of any size

B.   It obtains large blocks of memory from the system memory manager and allocates the memory to the application in smaller pieces.

C.   It hides memory leaks from the operating system

D.   All of the above answers are correct

8: What is the difference between eq and eql type predicates in Common Lisp?

A.   There are no such type predicates, so the question is incorrect

B.   eq is true only when tested object are the same identical object and eql is true only when tested objects have the same type and value

C.   eql is true only when tested objects are the same identical object and eq is true only when tested objects have the same type and value

D.   eq is a function, whereas eql is a macro.

9: What is amortized analysis is used for?

A.   To prove the stability of an algorithm.

B.   To analyze an algorithm behavior on random input data

C.   To find out the average algorithm performance in worst case

D.   None of the above

10: What is a bytecode interpreter?

A.   A program for the vulnerability analysis of a bytecode.

B.   A program for automatic translation of a bytecode from Unicode to UTF-8.

C.   A program which executes bytecode instructions.

D.   All of the above.

11: What is a generated code optimization method which is NOT suitable for use in a compiler?

A.   Code branching prediction

B.   Constants folding and propagation

C.   Loop invariant relocation outside

D.   Common subexpressions elimination in a code blocks

12: Which of the following sorting algorithms has average speed estimation defined as : O(n)?

A.   Counting sort

B.   Bucket sort

C.   Radix sort

D.   All of the above

13: What is the difference between a general binary search tree and an optimal binary search tree?

A.   An optimal binary search tree can be used only with unique nodes values

B.   An optimal binary search tree has less average expected search time as compared with a general binary search tree's one.

C.   An optimal binary search tree can not be used for solving optimization problems.

D.   All of the above

14: What is a heapsort?

A.   A phase in incremental garbage collection.

B.   A phase in generational garbage collection.

C.   A fast and memory-effective sorting algorithm.

D.   None of the above

15: What is an NP-complete problem?

A.   A problem which can not be solved using a Turing machine

B.   A problem which cannot be solved quickly.

C.   A problem which can not be solved without involving neural networks involvement

D.   None of the above

16: What is the difference between a Static Single Assignments graph (SSAG) and a Control Flow Graph (CFG) which are used for the intermediate compiled sources representation in a compiler?

A.   An SSAG is more suitable for a code optimization than a CFG.

B.   All SSAG graph elements have unique names but CFG ones do not.

C.   SSAG graph construction is much more complicated than CFG construction.

D.   All of the above.

17: Which of the following is NOT a standard Common Lisp type testing predicate?

A.   standard-string-p

B.   standard-char-p

C.   simple-bit-vector-p

D.   random-state-p

18: Which of the following is NOT a valid Common Lisp symbol name?

A.   ||||

B.   <><><>M<

C.   ?/?

D.   #?#

19: Which among the following is NOT a common element of parser internals?

A.   Finite state machine

B.   Indefinite state machine

C.   Petri net

D.   Language grammar rules interpreter

20: What branching instructions type is more resource-consuming on the RISC processor?

A.   Long branch instruction

B.   Short branch instruction

C.   All instructions are equal in CPU resources consumption

D.   RISC processor typically has only long branch instruction. The question therefore is incorrect

21: What functionality of the listed below is NOT common to a parser?

A.   Syntax errors handling in a program sources

B.   Semantic errors handling in a program sources

C.   Converting a program sources to a syntax tree

D.   Applying a language grammar rules to a program sources

22: What is the relationship between lexical and syntax analysis?

A.   They are one and the same thing.

B.   Lexical analysis includes syntax analysis.

C.   Syntax analysis includes lexical analysis

D.   They have no relationship with each other.

23: Which of the following options is NOT a technique used in "peephole optimization" of the generated code in a compiler?

A.   Sequential load and store instructions elimination

B.   Identifying patterns in the instruction stream which are known to be performance gaps

C.   Constants folding in the memory addresses used by the generated instructions

D.   Optimization of the generated code by performing branching analysis algorithms which take target machine characteristics into account

24: Assume that two instructions L1 and L2 are dependent in a flow graph. What does it mean when one says that they are output-dependent?

A.   They map to the same instruction position in the generated code

B.   They produce the same result when called

C.   They write to the same memory location when called

D.   They share the same output stream block in a code generation phase

25: What is the optimal way of copying the contents of one array to another in C language?

A.   By using the memcpy function.

B.   By using a loop.

C.   By using a SSE3 instructions for fast memory chunks movement.

D.   All of the above approaches are equivalent

26: What is the main advantage of using segregated lists usage in the manual memory management?

A.   They keep track of memory leaks in an application

B.   They allow to allocate memory chunks of any required size

C.   Memory management systems based on segregated lists are extremely fast

D.   All of the above

27: Which among the following is NOT a standard Common Lisp stream?

A.   *query-io*

B.   *terminal-input*

C.   *trace-output*

D.   *debug-io*

28:

What does the following Common Lisp line describes?

(vector 'integer 1234567890)

A.  

This is a vector of integer type whose absolute value can not be more than 1234567890


B.  

This is a vector of integers and its tag index is 1234567890


C.  

This is a vector of integers and its length is 1234567890  

D.  

This type definition is incorrect


29: Which of the following is a dispatch macro character in Common Lisp?

A.   `

B.   ,

C.   %

D.   #

30: What is the fastest way to establish a relationship between two objects?

A.   By using a hash map.

B.   By using a B-tree.

C.   By using a binary search tree.

D.   All of the above

31: What does it mean if when an algorithm "A", belongs to the O(n) algorithms:

A.   That algorithm

B.   That algorithm

C.   That algorithm

D.   None of the above

32: Which of the following is NOT a garbage collection algorithm?

A.   Train algorithm

B.   Baker algorithm

C.   Cheney algorithm

D.   Car algorithm

33: Is it possible to prove the theoretical stability (that is, prove that a collection algorithm will work as expected) of a garbage collector used in conjunction with C language?

A.   Yes, and in case of all garbage collector types.

B.   Yes, but only in the case of a generational garbage collector.

C.   Yes, but only in the case of an incremental garbage collector.

D.   It is not possible to prove the theoretical stability of any garbage collector type.

34: When using 'optional' keyword for declaring a lambda, such as 'optional (x y z)', what does x, y and z signify?

A.   They are all optional variables names

B.   x is a variable name, y is a binding flag and z is the default value for the variable x

C.   y is a variable name, x is a binding flag and z is the default value for the variable y

D.   x is a variable name, z is a binding flag and y is the default value for the variable x

35: Which of the following is NOT a garbage collection technique?

A.   Simple reference counting

B.   Deferred reference counting

C.   1-bit reference counting

D.   Composed reference counting

36: What is the main disadvantage of the bitmapped memory allocation scheme of the manual memory management?

A.   Bitmapped memory allocation scheme belongs to automated memory management methods, so question is incorrect.

B.   It is extremely hard to code on C and requires a great debugging effort before it starts working.

C.   Iit causes huge and frequent memory fragmentations.

D.   It allocates memory too slow.

37: When does a memory leak happen?

A.   It happens when a object created, is not destroyed.

B.   It happens when memory is still marked as used even after the object has been deleted.

C.   It happens when two objects hold references to each other and thus they cannot be deleted.

D.   All of the above

38: Which data structure does a compiler use to solve the register allocation problem?

A.   registers relation map

B.   registers interference graph

C.   registers dependency list

D.   registers allocation tree

39: What is the most important problem of the a conservative garbage collector?

A.   It has risk of misidentifying an application data as a heap pointer

B.   It tends to have memory leaks in its own implementation

C.   It is not suitable for use with low-level (such as C) languages

D.   It is the slowest type of garbage collectors

40: Which of the following is NOT a Common Lisp equality test predicate?

A.   e

B.   eq

C.   eql

D.   equal