🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #637

Re: AVL tree insertion - programming exercise

#637
From: Dan Cross
Date: Wed, 21 Oct 2026 11:22
76 lines
3723 bytes
In article <86h5ifo0g7.fsf@linuxsc.com>,
Tim Rentsch  <tr.17687@z991.linuxsc.com> wrote:
>cross@spitfire.i.gajendra.net (Dan Cross) writes:
>
>> In article <86v775h9o2.fsf@linuxsc.com>,
>> Tim Rentsch  <tr.17687@z991.linuxsc.com> wrote:
>>
>>> cross@spitfire.i.gajendra.net (Dan Cross) writes:
>>>
>>>> In article <11al4mu$fqtl$1@kst.eternal-september.org>,
>>>> Keith Thompson  <Keith.S.Thompson+u@gmail.com> wrote:
>>>>
>>>>> David Brown <david.brown@hesbynett.no> writes:
>>>>>
>>>>>> On 13/10/2026 10:38, chine.bleu wrote:
>>>>>>
>>>>>>> Tim Rentsch wrote:
>>>>>>>
>>>>>>>> sons[2] array.  These links are basically pointers, but held
>>>>>>>> as uintptr_t so they can take one of the bits to mean "tall",
>>>>>>>> which means taller than the other subtree of the node.  The
>>>>>>>> tree structure should maintain an invariant that at most one
>>>>>>>
>>>>>>> Memory is cheap.
>>>>>>
>>>>>> Not any more!
>>>>>>
>>>>>>> Do not encode tags into low bits of an address unless you really
>>>>>>> know what your doing.
>>>>>>
>>>>>> Agreed, as a principle.
>>>>>>
>>>>>>> As a precaution check the return address of malloc
>>>>>>>      p = malloc(m);
>>>>>>>      if ((uintptr_t)p)&1!=0) abort();
>>>>>>
>>>>>> malloc always returns an address with suitable alignment for any
>>>>>> fundamental alignment on the target.
>>>>
>>>> I don't think this is true anymore, as of C23.  Here's the
>>>> relevant text from n3220, sec 7.24.3, describing the return
>>>> value from `malloc` et al:
>>>>
>>>> |The pointer returned if the allocation succeeds is suitably
>>>> |aligned so that it may be assigned to a pointer to any type of
>>>> |object with a fundamental alignment requirement and size less
>>>> |than or equal to the size requested.
>>>>
>>>> This sentence is somewhat ambiguous because it's unclear whether
>>>> the "less than or equal to the size requested" criteria applies
>>>> to both the pointer type's size _and_ fundamental alignment
>>>> requirement, or _just_ the size, [...]
>>>
>>> It's poorly constructed but in English it has only one
>>> grammatical parse.
>>
>> Nope.  Not even close.
>
>I am confident my assessment is on fairly solid ground in this
>case.

You don't have to be confident; you can simply show data.

One can simply run the sentence through a grammar analyzer using
a standard grammar model, like spaCy (Stanford), using a tool
like the NLP toolkit, and see what comes out.  Using a fairly
strict model, that single sentence yields well over a thousand
valid parses.

>That said, I don't think there is any value in taking part in a
>shouting match, which seems to be all you want to do here.

I am not shouting.  You simply made a factual error.  *shrug*

	- Dan C.
Technical Details
Message-ID: <11ba798$9qs$1@reader2.panix.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
References: <86ece2kppv.fsf@linuxsc.com> <86v775h9o2.fsf@linuxsc.com> <11am74c$54g$1@reader2.panix.com> <86h5ifo0g7.fsf@linuxsc.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cross@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.lang.c
Subject: Re: AVL tree insertion - programming exercise
Date: Wed, 21 Oct 2026 11:22:16 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <11ba798$9qs$1@reader2.panix.com>
References: <86ece2kppv.fsf@linuxsc.com> <86v775h9o2.fsf@linuxsc.com> <11am74c$54g$1@reader2.panix.com> <86h5ifo0g7.fsf@linuxsc.com>
Injection-Date: Wed, 21 Oct 2026 11:22:16 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
	logging-data="10076"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)