Which of the following concepts can be used to identify loops? A. Depth first…
2021
Which of the following concepts can be used to identify loops?
A. Depth first ordering
B. Dominators
C. Reducible graphs
Choose the correct answer from the options given below:
- A.
A and B only
- B.
A and C only
- C.
B and C only
- D.
A, B and C
Attempted by 73 students.
Show answer & explanation
Correct answer: D
Answer: All three concepts — Depth-first ordering, Dominators, and Reducible graphs — can be used to identify loops.
Key ideas:
Depth-first ordering: A DFS of the control-flow graph classifies edges and exposes back edges (edges to ancestors). Each back edge signals a loop and is used to form the natural loop around the loop header.
Dominators: Dominator analysis identifies nodes that must be passed to reach others; a back edge from a node to one of its dominators indicates a natural loop with that dominator as the unique loop header, and the dominator tree helps determine loop nesting.
Reducible graphs: If a control-flow graph is reducible, its loops are guaranteed to be natural (single-entry), which makes standard loop-detection techniques (based on back edges and dominators) correct and simpler to apply.
Note: Strongly connected components also detect cycles in general graphs, but dominator and back-edge based methods specifically identify natural single-entry loops; reducibility is the structural property that guarantees this form.
A video solution is available for this question — log in and enroll to watch it.