Pseudocode to compare two trees
问题 This is a problem I've encountered a few times, and haven't been convinced that I've used the most efficient logic. As an example, presume I have two trees: one is a folder structure, the other is an in-memory 'model' of that folder structure. I wish to compare the two trees, and produce a list of nodes that are present in one tree and not the other - and vice versa. Is there an accepted algorithm to handle this? 回答1: Seems like you just want to do a pre-order traversal, essentially. Where