7 ms·
Show HN: Python library for learning binarytrees
- deleted 8y ago[deleted]
- palgraham 8y agothat's a large __init.py__
- FlyingLawnmower 8y agoI really like the idea of libraries that make it easy to learn a data structure/algorithm/general concept. Thank you for publishing this! It will certainly make CS concepts easier to teach.
- 01100011 8y agoI was just thinking of writing something like this to practice algorithms. Glad to see it exists already.
- aldanor 8y agoMinor suggestion: I would replace 'learning' with 'studying' for clarity, since "learning trees" instantly associates with gradient boosting (e.g. xgboost/lightgbm) in machine learning.
- juwani 8y agoDone!
- paidleaf 8y agoOr 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.
- SurrealSoul 8y agoSemi-off topic, but I recently had a binary tree interview question and it made me think about if I ever implemented a binary tree aside from a college course. Has anyone ever used a binary tree in production code somewhere? The closest thing I used was a linked list
- bhagone 8y agoThank you
- btispentest02 8y agoyou could learn algorithms properly <O_O> https://algs4.cs.princeton.edu/home/ https://algs4.cs.princeton.edu/home/
- btispentest01 8y agohttps://algs4.cs.princeton.edu/30searching/ https://algs4.cs.princeton.edu/30searching/