Mark As Completed Discussion

Visualizing the Merging Process

The picture truly is worth a thousand words. In this diagram, we see Tree 1 with a root node of 3 and Tree 2 with a root node of 1. As per our observation #1—"Roots Merge"—we combine these roots to create a new root for the merged tree, which has a value of (3 + 1 = 4).

Step Six

The Steps in the Process

  1. Start at the Roots: We begin with the root nodes of both Tree 1 and Tree 2. These are 3 and 1, respectively.

  2. Merge the Roots: We add the values of these root nodes together. (3 + 1 = 4)

  3. Create the Merged Root: We then use this sum to create the root node of our new, merged tree.

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment