Jill Ceke wrote:

[...] I follow it until we add the 4 node. How do we determine that the insertion of 4 goes to the bottom right leaf position of 3 instead of the bottom left leaf position?

You can see node 3 as the root of an extensible subtree that can get two children.

4 is added to the right child of this subtree because it's greater than the subtree's root (parent), which is 3.

Jill Ceke wrote:

[...] Inserting the fourth node, 7, went down through 18 instead of 3. Is there a particular reason why?

7 is greater than 5, so it goes to the right child, and 7 is less than 18, so it goes to node 18 subtree's left child.

Jill Ceke wrote:

Assuming that is the correct way, inserting 11 would switch the 11 and 18 spots, but wouldn't having 18 as the parent node,

7 as left child, and 11 as right child adhere to the principle of left child smaller than parent and smaller or equal to right child?

No, at first 11 belongs to the left child because it's less than its parent, which is 18.

Then a right rotation occurs to balance the subtree:

The left child becomes the parent which becomes the right child, and the left leaf becomes the left child.

P.S.: Are you really using a binary tree implementation in

**bash**(1)? How come you need it?