queue.extend(node)
queue.extend([node])
queue.extend(node.children)
Sure, I could take a guess which one of those appends the contents of "node" to the end of "queue", but I'd be guessing about syntax, not programming.After that, and question 3 about what happens when you assign to a function argument, I realized it was a Python quiz and stopped reading.
From a python-specific viewpoint, dequeue.extend appends a given list to the end of the queue. The first example will raise an exception, but the other two are perfectly valid, and their behavior isn't special to python - it's just asking whether you'll want to vi it this same node again, or the node's children.
Incidentally, it's not as if there's any standard library 'node' class with a children method. This was a structure they defined, but did not share the definition of.
Ahh, that makes things much clearer. Since they weren't otherwise mentioned, I supposed that "value" and "children" were properties of some existing Python collection object - and that the question was asking how "queue.extend" expected that collection to be passed in.
I guess this is the inverse of a language-specific question - if one knows that "children" has no significance in Python then I suppose the question would be clearer.
# assume "node" is an object with "value" and "children" properties
would make this question clearer.