Question:medium

Show Hint

To count basic blocks, look for the jumps or conditional statements ("if" or "goto") that affect the flow. Each section of the code between these jumps forms a basic block.
Updated On: Jan 30, 2026
Show Solution

Correct Answer: 6

Solution and Explanation

The program can be divided by observing the points where control flow may either enter from elsewhere or branch out to another part of the code. Each uninterrupted sequence of statements between such control-flow boundaries forms a single unit of execution.

In the given code, new execution segments begin:

  • at the start of the program,
  • immediately after each conditional jump target, and
  • immediately after each conditional jump instruction.

Examining the jump targets and conditional branches reveals that the program naturally partitions into six such uninterrupted segments, each having a single entry point and a single exit point.

No two of these segments can be merged without violating the definition, since doing so would introduce either multiple entry points or internal branches.

Hence, the total number of basic blocks in the code is \(\boxed{6}\).

Was this answer helpful?
0

Top Questions on Memory hierarchy