Setting up the test data and pretty printing the tree is part of the learning process. I'd say it is essential.
Writing pretty printers for trees is one of the best ways to verify you actually know how a tree works rather than having a superficial understanding of it.
> It's very odd that you have chosen to declare this "improper" and discredit it as a result of your own misunderstanding.
Because that's not the proper way to learn binary trees. I felt I gave good reasons for why. You learn binary trees by building one yourself. That's the best way.
So you use data provided by others. You use pretty printers provided by others. You use implementation provided by others. So what have you learned?
Part of the learning process, especially in algorithms, is creating your own data ( to test edge cases, speed, etc ). Part of learning is setting up your own pretty printer because it sure isn't trivial the first time you do it.
Something as fundamental like binary trees and algorithms should be taught/learned properly.
> You learn binary trees by building one yourself. That's the best way.
Sure - do it once, but if you're trying to wrap your head around a new algorithm or just trying to focus on one particular problem, it's very de-motivating to not have quality debug-printers, random-data-generators, etc.
Story: I was once trying to wrap my head around heap.remove() (and the associated sift-up) and I had my own tree class and various ways to print and inspect it. I couldn't for the life of me figure out why my sift wasn't working. Wasted like an hour on it. Turns out it was working, it was just my printing/test-harness stuff that was flawed. Sure that was a useful hard-knock, but it really served as a distraction from what I was trying to do at the moment. Made me stop doing tree katas for a few weeks out of frustration.
> Something as fundamental like binary trees and algorithms should be taught/learned properly.
"Properly" is pejorative here. I would say this class/lib is an extremely useful part of learning more advanced tree/algo concepts properly.
Having a helper class that solves some of the basics well and sets you up for success lets you focus on the larger problems without having to constantly re-visit the basics. It's how abstractions are made and learned.
> I couldn't for the life of me figure out why my sift wasn't working. Wasted like an hour on it. Turns out it was working, it was just my printing/test-harness stuff that was flawed. Sure that was a useful hard-knock, but it really served as a distraction from what I was trying to do at the moment.
What you think is an unnecessary distraction is in my opinion a very important experience and part of the learning process. Everything you hand-code for your own data structure be it pretty-print, test-harness, etc. are all important while learning.
> Having a helper class that solves some of the basics well and sets you up for success lets you focus on the larger problems without having to constantly re-visit the basics.
Once you have built the data structures bottom-up from scratch along with all the additional utilities to pretty-print it, test it, etc. you have your helpers ready already. There is no need to use someone else's helpers at that point.
Writing pretty printers for trees is one of the best ways to verify you actually know how a tree works rather than having a superficial understanding of it.
> It's very odd that you have chosen to declare this "improper" and discredit it as a result of your own misunderstanding.
Because that's not the proper way to learn binary trees. I felt I gave good reasons for why. You learn binary trees by building one yourself. That's the best way.
So you use data provided by others. You use pretty printers provided by others. You use implementation provided by others. So what have you learned?
Part of the learning process, especially in algorithms, is creating your own data ( to test edge cases, speed, etc ). Part of learning is setting up your own pretty printer because it sure isn't trivial the first time you do it.
Something as fundamental like binary trees and algorithms should be taught/learned properly.