4 ms·
Or you could learn algorithms properly https://algs4.cs.princeton.edu/home/ https://algs4.cs.princeton.edu/home/ https://algs4.cs.princeton.edu/30searching/ h
by paidleaf 8y ago
Or you could learn algorithms properly
https://algs4.cs.princeton.edu/home/ https://algs4.cs.princeton.edu/home/
https://algs4.cs.princeton.edu/30searching/ https://algs4.cs.princeton.edu/30searching/
and write your own trees.
There is a free coursera course that goes along with the princeton algorithm website. Also this website has tons of exercises to help you master the subject. Not to mention all their code is freely available ( though it is in Java, not python ).
I'm a believer of learning by doing. Using something others have built for you isn't an optimal way of learning anything. Especially binary trees and the more encompassing subject of algorithms.
- foo101 8y agoExactly this! If you are learning algorithms, you should be implementing your own trees rather than relying on a library like this that does the work for you. The real benefit of learning algorithms comes when you put the hard work into it to build the data structures in a bottom up manner. Using someone else's tree generating library eliminates this experience which is a vital experience in the journey of learning algorithms.
- bogomipz 8y agoExcept the use case for this is not meant as a substitution for "hard work." It's a convenience library. This is no different than importing the Python's standard library's queue, dequeue, hash etc for use in studying algorithms that use those data structure after you understand how to implement them by hand.
- bogomipz 8y agoIt was clear to me as well as some other commenters here that the point in this library is to practice algorithms on binary trees and pretty print their output. Studying algorithms while using a library for the implementation of the underlying data structure is still very much "learning by doing." This assumption being that you already understand how to implement that data structure and would like to concentrate on studying algorithms on that data structure. It's very odd that you have chosen to declare this "improper" and discredit it as a result of your own misunderstanding. The documentation clearly states the author's intentions: "It allows you to skip the tedious work of setting up test data, and dive straight into practising your algorithms."[1] [1] https://binarytree.readthedocs.io/en/latest/index.html https://binarytree.readthedocs.io/en/latest/index.html
- paidleaf 8y agoSetting 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.
- ryanianian 8y ago> 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.
- 8y ago