Article View: comp.lang.c
Article #127Re: AVL tree insertion - programming exercise
From: Michael S
Date: Sat, 10 Oct 2026 20:00
Date: Sat, 10 Oct 2026 20:00
32 lines
2814 bytes
2814 bytes
On Sat, 10 Oct 2026 12:39:09 -0700 Andrey Tarasevich <noone@noone.net> wrote: > On Tue 10/6/2026 11:08 PM, Tim Rentsch wrote: > > I offer this small programming exercise for anyone who is > > interested. > I did exactly that a couple of months ago, except that my case the > AVL tree was intended to serve as a carrying sub-structure for an > augmented interval tree. I did not make any effort to decouple the > implementations, meaning that my AVL implementation is intermixed > with the interval tree implementation. > > Also, I had to support not only operations that start from the root > of the tree (like your `add_key`), but also operations that start > from a specific arbitrary node (e.q. a `delete_node(Node *)` > operation). So, in my case I opted to also keep and maintain the > parent link in each node. Extra memory expenditure is not that > drastic, especially considering the fact that my nodes are already > heavier - carrying geometric data for the interval tree. > > Meanwhile, you seem to be striving to squeeze out all "unnecessary" > memory usage (re: embedding the balance value into the unused pointer > bits). Is this a hard requirement in your exercise? > I also did it relatively recently (2 or 3 years ago) and also in specialized context (median filtering) so not sure how applicable my solution would be here. BTW, at the end AVL tree didn't ended up as my data structure of choice for this particular application, but it did ended up as a solid contender with the same BigO characteristics as a winner.
Technical Details
Message-ID:
<20261010230047.000026b0@yahoo.com>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> <11ae48u$21bo6$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: Michael S <already5chosen@yahoo.com> Newsgroups: comp.lang.c Subject: Re: AVL tree insertion - programming exercise Date: Sat, 10 Oct 2026 23:00:47 +0300 Organization: A noiseless patient Spider Lines: 32 Message-ID: <20261010230047.000026b0@yahoo.com> References: <86ece2kppv.fsf@linuxsc.com> <11ae48u$21bo6$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Date: Sat, 10 Oct 2026 20:00:54 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1971962"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SoCoVfQOlrExl9ejZ2BAoRtNgxOGTT7I="; posting-host="49690832da79aa746ce4261de989d20e" Cancel-Lock: sha1:SVGA9f+lNVYphsSoUUhyJ/NH4Ic= sha256:cKmHlo7n3/6xk3Pdo2bpACSYNTgckRR7h1IWlJxPPAQ= sha1:1SxfRGf49kJF3GJcD8OqNrvrsxs= sha256:CFGD7JRhHoaPqiZ/32vew/9UhemhO/9feldv/p2Q5N4= X-Newsreader: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)