Article View: comp.lang.c
Article #134Re: AVL tree insertion - programming exercise
From: Janis Papanagnou
Date: Sat, 10 Oct 2026 20:28
Date: Sat, 10 Oct 2026 20:28
33 lines
2720 bytes
2720 bytes
On 2026-10-10 21:39, Andrey Tarasevich wrote: > [ AVL-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). We don't need a parent-reference to delete an actual referenced node, do we? In my Algol 68 implementation I'm using a "REF REF NODE" type (let's call that a pointer reference for better understanding) that makes it possible to operate on a higher indirection level. (In C++ that might be implemented with &*, and in "C" emulated with **, I'd suppose, and in Pascal I had done that with a 'var' parameter on a pointer type; I don't recall to have implemented that in "C" myself but I don't see that it wouldn't be feasible.) > 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 recall I've done such a hack in the 1980's on an Atari where memory was scarce to implement a 'tries' data structure. Janis
Technical Details
Message-ID:
<11ae75l$cjm0$5@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> <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: Janis Papanagnou <janis_papanagnou+ng@hotmail.com> Newsgroups: comp.lang.c Subject: Re: AVL tree insertion - programming exercise Date: Sat, 10 Oct 2026 22:28:37 +0200 Organization: A noiseless patient Spider Lines: 33 Message-ID: <11ae75l$cjm0$5@dont-email.me> References: <86ece2kppv.fsf@linuxsc.com> <11ae48u$21bo6$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 10 Oct 2026 20:28:38 +0000 (UTC) Injection-Info: dont-email.me; logging-data="413376"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/JB3L3cNbx0US7PJ8VcJTB"; posting-host="51a9598490edb80150aa60ca9e0cee6b" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:O0qdJL1Nw1bN2QLA38I6kYhKGBk= sha256:FUvknxtuHWnUox9uqK20vooSk2QCWkJMB008Ge3XoVM= sha1:Q46VJ+W8GqwYk6QN2GgRv+AXCT4= sha256:PRQXco8MEqpdm3LL4lZ/dwamNc7CS1ul/AespfINtfg= Content-Language: en-US In-Reply-To: <11ae48u$21bo6$1@dont-email.me>