Article View: comp.lang.c
Article #77Re: AVL tree insertion - programming exercise
From: Janis Papanagnou
Date: Fri, 09 Oct 2026 10:27
Date: Fri, 09 Oct 2026 10:27
77 lines
5302 bytes
5302 bytes
On 2026-10-09 10:34, David Brown wrote: > On 09/10/2026 08:53, Tim Rentsch wrote: >> BGB <cr88192@gmail.com> writes: >>> On 10/8/2026 7:56 AM, Tim Rentsch wrote: >> >>>> I learned about AVL trees from The Art of Computer Proggramming, >>>> by Knuth. I'm sure there are other explanations available but I >>>> don't have any other pointers to give you. >>> >>> I read about them at some point when I was younger, and used them >>> occasionally. [...] >> >> I encourage you to read the description in Knuth TAOCP. > > I would not recommend that, any more than I would recommend "The C > Programming Language" to someone wanting to learn C. > > Knuth's detailed mathematical treatment of algorithms is second to none, > and his contribution to computer science is legendary. His writing > style is wonderful, and I thoroughly enjoyed the TeXbook (though it left > me with a serious disability - I am now unable to read text without > being annoyed at typographic flaws or inconsistencies!). (Hah! - And I thought I'm a rare case here, being [in my vicinity] the only one who seems to be suffering from bad typesetting. - I didn't need his book, though - actually I haven't read his book on TeX - since these bad feelings appeared as soon as MS word came out, and Ariel fonts, and similar typographical steps backwards. It's characteristic; you look at a book and can immediately make an educated guess whether it had been typeset using TeX, Nroff, MSWord, or something else.) > > But it is /not/ a book you use to learn a new topic. It is not a book > you use to learn about AVL trees (it does not even mention them by that > name), either in terms of what they are used for, how they work, or how > they may be implemented. You will learn more that is relevant to you > from an animated gif on the Wikipedia page than from reading the entire > chapter in "Fundamental Algorithms". > > If you want to understand how you can prove the algorithmic complexities > of different tree structures and their algorithms, and to better > understand how to prove the tree invariants, and to better understand > how to make your own interesting tree structures - /then/ studying that > part Knuth's book could be useful. It is not a book you read, it is > something you have to study. I very much agree on everything you wrote here. The unfortunate part of the story is that a lot of the literature on that (unless referring to the original authors of the AVL tree) is obviously [still] based on or inspired by Knuth's book. (One detail is the already mentioned representation of the balancing property. Even Wikipedia still shows that form, but at least they explicitly mention that they based their representation on Knuth and that using the height is an equivalent option.) > > And like "The C Programming Language", it suffers from age - you can't > learn modern C from a 50 year old book, and you can't learn modern > coding from a 60 year old book. Far and away the biggest mistake of the > books - IMHO - is the use of a mythical assembly as the language for the > programs instead of a high-level pseudo-code that made the interesting > stuff clear instead of bogging it down in irrelevant detail. Indeed. - It's many years that I had TAOCP in my hands but I seem to recall that he also wrote (in that specific language) everything in iterative form. That is especially bad in case of recursive data structures and algorithms - we recently discussed that here! - that are (IMHO) a lot clearer than any iterative code on tree structures. With the Internet resources we luckily have a rich source of more recent and refined information about that topic. (The problem there is only to sort the wheat from the chaff.) Janis
Technical Details
Message-ID:
<11aafhp$cjm0$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<86ece2kppv.fsf@linuxsc.com> <11a5h8m$2t8e8$1@dont-email.me> <865wzdl3xz.fsf@linuxsc.com> <11a6qi4$3cv2b$1@dont-email.me> <86wlrsjqq9.fsf@linuxsc.com> <11a8ta9$6463$1@dont-email.me> <86jynrjrf3.fsf@linuxsc.com> <11aa8vb$jk93$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com> Newsgroups: comp.lang.c Subject: Re: AVL tree insertion - programming exercise Date: Fri, 9 Oct 2026 12:27:05 +0200 Organization: A noiseless patient Spider Lines: 77 Message-ID: <11aafhp$cjm0$1@dont-email.me> References: <86ece2kppv.fsf@linuxsc.com> <11a5h8m$2t8e8$1@dont-email.me> <865wzdl3xz.fsf@linuxsc.com> <11a6qi4$3cv2b$1@dont-email.me> <86wlrsjqq9.fsf@linuxsc.com> <11a8ta9$6463$1@dont-email.me> <86jynrjrf3.fsf@linuxsc.com> <11aa8vb$jk93$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 09 Oct 2026 10:27:06 +0000 (UTC) Injection-Info: dont-email.me; logging-data="413376"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yvs68wirpr+QDdHwAUNG5"; posting-host="5df2e382f4c85fd5e765438f10ef664f" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:TSLY5GVPoDg1k3bJzuAzqohuLgA= sha256:8eFAPN5vw3pW2uuLO5AidIBOQHjnwdaWRY/lknTHUMk= sha1:Mv40siFq6U3dwhJarVnrgkd9JBE= sha256:DM7C2nHKclqBmGLzmqqgIYkKTFYWy2Bxy1B+RxR1LGk= Content-Language: en-US In-Reply-To: <11aa8vb$jk93$1@dont-email.me>