GATE 2002
56 questions
MCQ 561-mark 56
Questions 41–45 of 56
Answer: (A)
Look at the state. A is entered only on input 0, so in A the previous bit is 0. B is entered only on 1 from A, and C only on 1 from B or C. So in B and C the previous bit is 1.
Check every arc:
A, input 0: . The arc is 0/00.
A, input 1: . The arc is 1/01.
B, input 0: . The arc is 0/01.
B, input 1: . The arc is 1/10.
C, input 0: . The arc is 0/01.
C, input 1: . The arc is 1/10.
All six arcs match, so (A) is true.
(B) is wrong: for input 11 the second 1 gives output 10, not 01. (C) is wrong: for input 10 the 0 gives output 01 (from B), not 00.
Answer: (A)
Answer: (B)
Correct Option: B
The stack can hold only a limited number of items, so the number of possible configurations is finite. Each of these configurations can be treated as a state of a finite automaton.
Answer: (B)
- a variable must be declared before it is used, which needs a comparison of the name used with the whole list of names declared (like matching the string with a copy of that comes later), and
- the formal parameters and the actual parameters of a function must match in number (and type).
These are context-sensitive conditions, not context-free ones, so the language of valid C programs is a context-sensitive language. It is not regular, since it has nested brackets which need a stack. It does not need a full Turing machine: a linear bounded automaton is enough to parse it.
Answer: (B)
Answer: (A)
A recursive language has a total Turing machine. This is a machine that always halts, and it either accepts or rejects. If we complement a recursive language, we swap accept and reject in that machine, as in the figure. It still always halts, so the complement is also recursive. This makes (A) true.
A recursively enumerable language has a Turing machine with three possible outcomes: accept, reject or loop. So its complement may be recursively enumerable, or it may not even be recursively enumerable. For example, the halting language is RE, but its complement is not. So (B) is false.
Context-free languages are not closed under complement. Take and , which are context-free. Their intersection is not context-free. If CFLs were closed under complement, they would be closed under intersection too (as ). So (D) is false.
Option (C) says the complement of a recursive language is recursive or recursively enumerable. This is also true, because a recursive complement is already one of the two. But it is weaker than (A), which says exactly what the complement is. So (A) is the best option.
Answer: (A)
Answer: (B)
(A) False. If main calls f, f calls g and g calls h, then f and g are both between h and main. Calls can be nested to any depth.
(B) True. The number of records between the current one and main equals the depth of calls at that moment, so it depends on the actual calling sequence.
(C) False. C uses static (lexical) scoping, so which global variables are visible is fixed by the program text, not by who called whom.
(D) False. A recursive call is treated like any other call. Its record is pushed on the same stack, and no separate stack is needed.
Answer: (B)