• edited by
411 views
1 1 vote

Consider the following intermediate code segment:
\[
\begin{array}{l}
\verb|(1) a = 1| \\
\verb|(2) if a > 0 goto (4)| \\
\verb|(3) a = a * 2| \\
\verb|(4) b = 5| \\
\verb|(5) if b < 10 goto (10)| \\
\verb|(6) a = a + b| \\
\verb|(7) b = b + 1| \\
\verb|(8) b = b * 3| \\
\verb|(9) goto (5)| \\
\verb|(10) return a|
\end{array}
\]
The number of nodes and edges in the control-flow graph constructed for the above code, respectively, are:

  1. $6$ and $7$
     
  2. $8$ and $10$
     
  3. $5$ and $6$
     
  4. $6$ and $8$

3 Answers

1 1 vote
There are 6 leaders: $1,3,4,5,6,10$

Hence no of nodes $=6+2=8$

there are $7$ sequential edges (including $2$ edges for entry and exit node) and $3$ goto edges

so no of edges $=7+3=10$
Answer:
Position:
Show:

Related questions

2 2 votes
2 2 answers
350
350 views
GO Classes asked Dec 4, 2025
350 views
Consider the following intermediate code segment:\[\begin{array}{l}\verb|(1) x = 0| \\\verb|(2) y = 10| \\\verb|(3) if x < y goto (5)| \\\verb|(4) x = x + 1| \\\verb|(5) ...
3 3 votes
3 3 answers
381
381 views
GO Classes asked Dec 4, 2025
381 views
Consider the following code segment:\[\begin{array}{l}\verb|z = a - b;|\\\verb|x = 3 * z;|\\\verb|y = z + 10;|\\\verb|z = x + y;|\\\verb|a = y / 2;|\\\verb|x = a * z;|\en...
2 2 votes
1 1 answer
423
423 views
GO Classes asked Dec 4, 2025
423 views
Consider the control flow graph given below:\begin{array}{lll}\text { Basic Block } & \text { Statements } & \text { Control Flow Edges } \\\textbf { B1 } & i=1 & \mathrm...
2 2 votes
3 3 answers
380
380 views
GO Classes asked Dec 4, 2025
380 views
Consider the control flow graph below :\[\begin{array}{|l|l|l|}\hline\text{Basic Block} & \text{Statements} & \text{Control Flow Edges} \\\hline\textbf{B1} & a=b+c ;\ d=a...