Home > Reflections | ⏮️ ⏭️
2024-06-26
🏋️ Coding Practice
545. Boundary of Binary Tree
The boundary of a binary tree is the concatenation of the root, the left boundary, the leaves ordered from left-to-right, and the reverse order of the right boundary.
The left boundary is 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 no left child, but has a right child, then the right child is in the left boundary.
- The leftmost leaf is not in the left boundary.
The right boundary is similar to the left boundary, except it is the right side of the root’s right subtree. Again, the leaf is not part of the right boundary, and the right boundary is empty if the root does not have a right child.
The leaves are nodes that do not have any children. For this problem, the root is not a leaf.
Given theroot
of a binary tree, return the 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