projects:proof:populatedifftree
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| projects:proof:populatedifftree [2023/02/27 18:02] – [Checking for new nodes] Owen Mellema | projects:proof:populatedifftree [2023/02/27 19:22] (current) – Owen Mellema | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| The purpose of this algorithm is to add information to a tree about what will change in another tree. This includes information about creation and deletion of nodes, as well as movement. | The purpose of this algorithm is to add information to a tree about what will change in another tree. This includes information about creation and deletion of nodes, as well as movement. | ||
| - | We are given two trees - an **original** tree and a **modified** tree. In the image below, the left tree is original, and the right tree is modified. | + | We are given two trees - an **original** tree and a **modified** tree. The original tree will have the new information added. In the image below, the left tree is original, and the right tree is modified. | 
| {{: | {{: | ||
| Line 49: | Line 49: | ||
| We do this for each pair of matched nodes. On this level, there are no mismatched nodes, but there will be in the next level, under node F. | We do this for each pair of matched nodes. On this level, there are no mismatched nodes, but there will be in the next level, under node F. | ||
| - | ==== Checking | + | ==== Scanning | 
| Next, we check if we need to add new nodes. We start in the modified tree, scanning for any nodes that are unmatched. | Next, we check if we need to add new nodes. We start in the modified tree, scanning for any nodes that are unmatched. | ||
| Line 82: | Line 82: | ||
| There are no more unmatched nodes in the modified tree. | There are no more unmatched nodes in the modified tree. | ||
| + | |||
| + | ==== Scanning for, and handling, deletion ==== | ||
| + | |||
| + | Handling deletions is really simple. | ||
| + | |||
| + | We start at the first node in the original tree, and scan for unmatched nodes. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | When we find one, we mark it as deleted. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | That's literally it - we don't need to actually delete any nodes, we just need a node telling us that we deleted a node. | ||
projects/proof/populatedifftree.1677520951.txt.gz · Last modified: 2023/02/27 18:02 by Owen Mellema
                
                