Talk:Pre-order traversal

Not too clear, this one...

Yeh, I'll try to add some more detail to it.

As described this can surely only refer to binary trees, and this is, I think, the normal usage. However, if a tree is defined in terms of nodes, and list of trees - something like ...

e.g

data Tree a = Node a | (Node a, [ Tree a])

.... you might prefer

data Tree a = EmptyTree| (Node a, [ Tree a])

then the generalisation would be to recursively visit the node first, followed by each tree in the list in list order. Postorder could be defined in a similar fashion, but inorder would then be meaningless.

Someone might want to clarify this. I suspect that most functional programming practitioners would be happy with the generalisations.

David Martland 11:03 Apr 8, 2003 (UTC)