Machine-translated by Google. Questions are authored in English.
Top

Discussion

The expression a + b + a + b is represented as a directed acyclic graph with sharing. How many distinct interior nodes does it have?

  • A.1
  • B.2
  • C.3
  • D.4

Answer: B

In a directed acyclic graph, identical subexpressions are built once and shared. Here \( a+b \) occurs twice but becomes a single node, and the outer addition that combines the two references is a second: \[ \text{interior nodes} = 1 \ (a+b) + 1 \ (\text{outer} +) = 2 \] A plain syntax tree, which cannot share, would carry three interior nodes for the same expression.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.