|
I have my suspicions of who created this one....
|
|
|
|
|
I'm absolutely 100% positive I couldn't.
Lucky for me I never needed it, but not a day goes by that I'm not afraid I'll have to do this and be exposed for the bad programmer that I apparently am
Edit:
Should anyone ever need this for whatever reason (those reasons would probably be evil), the first Google search result has your back: Convert a normal BST to Balanced BST - GeeksforGeeks[^]
I'll sleep a lot easier tonight, knowing the code is readily available
|
|
|
|
|
Sander Rossel wrote: I'll sleep a lot easier tonight, knowing the code is readily available Someone famous told once: Quote: I don't learn something I can find in my pocket.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
and I will find a solution, don't give me academic tests when I've been out of University 10 years ago.
Besides, you can call them Fnord Tree and R'lyeh Tree for what is worth.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
I've never needed anything like this in my long career as a developer...
|
|
|
|
|
I know that some libraries I use implement BTrees to do stuff but never ever in my 40 years coder life did I implement one.
That's what we use libraries for, isn't it ?
|
|
|
|
|
Not since college homework
|
|
|
|
|
if you've ever needed any kind of set/map/dictionary collection, it's probably using a self-balancing binary tree under the hood.
|
|
|
|
|
Way back in the '80s, I wrote my own implementation of a balanced BST in Pascal, using the algorithm I found in Knuth. If I had to, I could do it today by re-reading the book.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
I'd have to look up what exactly a Balanced tree was before I started - it's just been too long since I needed to know that for exams, and I've not had to create even a BST once since I left Uni.
I still think it's important to learn them though - so at least you know they exist if you do ned them at some point in your career, and can then try to remember how to implement one.
I just checked what a BBST is, and now I remember. I did it a few times at Uni, and I could do it in about twenty minutes or so including testing. Maybe half an hour - setup of the node structure and sample data for testing is a little time consuming.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: it's just been too long since I needed to know that for exams, and I've not had to create even a BST once since I left Uni. I had not even to create one during studies...
OriginalGriff wrote: o at least you know they exist if you do ned them at some point in your career, and can then try to remember how to implement one. I know that they exist, but had never need them (yet)
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|