Reputation: 2876
I have seen many examples of AST doing arithmetic operations
which look like this:
+
/ \
1 2
above represent 1 + 2
. My question is, are all ASTs binary by definition or a node could possibly have more than 2 children?
Upvotes: 1
Views: 1347
Reputation: 1351
Yes, in an AST, nodes often have more than two children. For example, a block of code is typically a node with an array of child nodes, which are statements.
Upvotes: 1