GATE 2023
65 questions
MCQ 34 · MSQ 15 · NAT 161-mark 30 · 2-mark 35
Questions 11–15 of 65
Consider the following statements regarding the front-end and back-end of a compiler.
S1: The front-end includes phases that are independent of the target hardware.
S2: The back-end includes phases that are specific to the target hardware.
S3: The back-end includes phases that are specific to the programming language used in the source code.
Identify the CORRECT option.
S1: The front-end includes phases that are independent of the target hardware.
S2: The back-end includes phases that are specific to the target hardware.
S3: The back-end includes phases that are specific to the programming language used in the source code.
Identify the CORRECT option.
Answer: (B)
Let us check every statement one by one:
- The front end covers lexical, syntax and semantic analysis and intermediate code. It depends on the source language and not on the target machine So S1 is TRUE.
- The back end covers machine-level code optimization and code generation. It is specific to the target hardware So S2 is TRUE.
- The back end takes intermediate code as its input, so it does not depend on the source language So S3 is FALSE.
Answer: Only S1 and S2 are TRUE
- The front end covers lexical, syntax and semantic analysis and intermediate code. It depends on the source language and not on the target machine So S1 is TRUE.
- The back end covers machine-level code optimization and code generation. It is specific to the target hardware So S2 is TRUE.
- The back end takes intermediate code as its input, so it does not depend on the source language So S3 is FALSE.
Answer: Only S1 and S2 are TRUE
Which one of the following sequences when stored in an array at locations A[1], . . . , A[10] forms a max-heap?
Answer: (B)
In a max-heap, each parent must be both of its children, which are and .
- Option 1: A[3] = 10 has a child A[6] = 14. This is False.
- Option 2: 23 17, 14; 17 7, 13; 14 10, 1; 7 5, 6; 13 12. This is True.
- Option 3: A[5] = 13 has a child A[10] = 15. This is False.
- Option 4: A[4] = 1 has children 12, 7. This is False.
Answer: 23, 17, 14, 7, 13, 10, 1, 5, 6, 12
- Option 1: A[3] = 10 has a child A[6] = 14. This is False.
- Option 2: 23 17, 14; 17 7, 13; 14 10, 1; 7 5, 6; 13 12. This is True.
- Option 3: A[5] = 13 has a child A[10] = 15. This is False.
- Option 4: A[4] = 1 has children 12, 7. This is False.
Answer: 23, 17, 14, 7, 13, 10, 1, 5, 6, 12
Let SLLdel be a function that deletes a node in a singly-linked list given a pointer to the node and a pointer to the head of the list. Similarly, let DLLdel be another function that deletes a node in a doubly-linked list given a pointer to the node and a pointer to the head of the list.
Let n denote the number of nodes in each of the linked lists. Which one of the following choices is TRUE about the worst-case time complexity of SLLdel and DLLdel?
Let n denote the number of nodes in each of the linked lists. Which one of the following choices is TRUE about the worst-case time complexity of SLLdel and DLLdel?
Answer: (D)
To delete a node, we have to change the next pointer of its predecessor.
- Singly linked list: the only way to find the predecessor is to walk from the head .
- Doubly linked list: the prev pointer of the node gives the predecessor right away .
Answer: SLLdel is O(n) and DLLdel is O(1)
- Singly linked list: the only way to find the predecessor is to walk from the head .
- Doubly linked list: the prev pointer of the node gives the predecessor right away .
Answer: SLLdel is O(n) and DLLdel is O(1)
Consider the Deterministic Finite-state Automaton (DFA) shown below. The DFA runs on the alphabet {0, 1}, and has the set of states {s, p, q, r}, with s being the start state and p being the only final state.
Which one of the following regular expressions correctly describes the language accepted by ?
Which one of the following regular expressions correctly describes the language accepted by ?
Answer: (C)
Start at s: input 0 sends the DFA to the dead state r, so every accepted string must begin with 1, which takes it to the final state p.
At p: input 0 stays at p. Input 1 goes to q, and from q only another 1 goes back to p (input 0 goes to r).
So after the first 1, the string is made of repeats of "0" or "11": .
Answer:
At p: input 0 stays at p. Input 1 goes to q, and from q only another 1 goes back to p (input 0 goes to r).
So after the first 1, the string is made of repeats of "0" or "11": .
Answer:
The Lucas sequence is defined by the recurrence relation:
with
Which one of the options given is TRUE?
with
Which one of the options given is TRUE?
Answer: (A)
Take and . These follow , and .
Now test :
- This is true.
- This is true.
- The recurrence also holds, since both satisfy .
Answer:
Now test :
- This is true.
- This is true.
- The recurrence also holds, since both satisfy .
Answer: