Q96.Marks: +2.0UGC NET Paper 2: Computer Science 11 March 2023
Which of the following statements are correct?
A. The first three-address instruction in the intermediate code is a leader.
B. The instruction which is exactly at the middle of the given three address code is a leader.
C. Any instruction that is the target of a conditional or unconditional jump is a leader.
D. Any instruction that immediately follows a conditional or unconditional jump is a leader.
Choose the correct answer from the options given below:
1.A, B and C
2.B, C and D
3.A, C and D✓ Correct
4.A, B, C and D
Solution
The correct answer is A, C and D
Key Points
A. The first three-address instruction in the intermediate code is a leader.
Leaders, in programming, are the first instructions of a ‘basic block’ in the control-flow graph.
A basic block is a straight-line code sequence with no branches in except to the entry and no branches out except at the exit.
The first instruction of a basic block is known as a leader. So, in context, the first three-address instruction would be a leader as it's the first instruction in the block. This statement is correct.
B. The instruction which is exactly at the middle of the given three address code is a leader.
A leader doesn't get determined by its position in the middle of the given intermediate code. It becomes a leader if it's the first instruction in the block, or if it's the target of a conditional or unconditional jump, or if it immediately follows a jump. Just being at the "middle" doesn't qualify an instruction as a leader. Therefore, this statement is incorrect.
C. Any instruction that is the target of a conditional or unconditional jump is a leader.
This is correct. An instruction becomes a leader if it becomes the target of a jump - whether that jump is conditional or unconditional. That's because it marks a new possible entry point into a block of code, and thus starts a new basic block.
D. Any instruction that immediately follows a conditional or unconditional jump is a leader.
This statement is also correct. The instruction immediately following a conditional or unconditional jump also starts a new basic block. This is because the jump could transfer control elsewhere, and so the next instruction potentially starts a new sequence of code with no prior branches in.
So, summarizing, the correct statements here are A, C, and D, option 3.