Data Structures19 sections · 729 units
Open in Course

Path-Parent Pointer

Connecting auxiliary trees

Each auxiliary tree root has a path-parent: the parent in the original tree (not in the auxiliary tree).

class Node:
    left, right: Node        // children in auxiliary tree
    parent: Node             // parent in auxiliary tree
    pathParent: Node         // parent in original tree (only for aux tree roots)
    value: any               // node data

For non-root nodes in auxiliary tree: pathParent = null.

For roots of auxiliary trees: pathParent = parent in original tree.

You can traverse up the original tree by jumping between auxiliary trees.