Home > Reflections | ⏮️ ⏭️

# 2024-06-26

## 🏋️ Coding Practice

### 545. Boundary of Binary Tree

The

boundaryof a binary tree is the concatenation of theroot, theleft boundary, theleavesordered from left-to-right, and thereverse orderof theright boundary.

Theleft boundaryis the set of nodes defined by the following:

- The root node’s left child is in the left boundary. If the root does not have a left child, then the left boundary is
empty.- If a node in the left boundary and has a left child, then the left child is in the left boundary.
- If a node is in the left boundary, has
noleft child, but has a right child, then the right child is in the left boundary.- The leftmost leaf is
notin the left boundary.

Theright boundaryis similar to theleft boundary, except it is the right side of the root’s right subtree. Again, the leaf isnotpart of theright boundary, and theright boundaryis empty if the root does not have a right child.

Theleavesare nodes that do not have any children. For this problem, the root isnota leaf.

Given the`root`

of a binary tree, returnthe values of its.boundary

#### 🪞 Reflections

- 52 minutes is a long time
- 8:20 is too long for planning
- finishing the first implementation in ~12 minutes isn’t bad, but there were a couple of bugs
- testing took a long time, but it found several bugs
- But this is a pretty complicate problem, so maybe it’s not too bad

- I’m happy with the bugs I caught during manual testing
- The bug I didn’t catch during manual testing was a careless mistake
- I didn’t think about ordering the nodes properly on my first pass of the high-level implementation
- and I didn’t notice that my test result was not what it should have been (in terms of the order of nodes) at the end of testing
- but I was able to recognize the issue immediately and fixed it in one shot

- I’m happy with my recursive implementations
- I feel like working with trees is getting more natural