Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.c Subject: Re: Reinventing the wheel. Date: Mon, 24 Feb 2020 16:36:16 +0000 Organization: A noiseless patient Spider Lines: 26 Message-ID: <87y2ss3ptr.fsf@bsb.me.uk> References: <7ca1c103-6910-48ad-8eee-b2f47e7b1db0@googlegroups.com> <28c6d89d-1439-477a-ba1a-6d694deec7a1@googlegroups.com> <4451a8f8-84ea-4411-a4c8-f255ebad3ee3@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="87b29befd7e5e3660cb83cb7b77b6ffa"; logging-data="9372"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18orEt16RonnBDRwhHwmg+weXI6TsI0PMg=" Cancel-Lock: sha1:3wRvu2kXrnxsEjM14j0vv+NjZIM= sha1:b951qZyUSLMOBbE6nR6H+3raC6I= X-BSB-Auth: 1.5ad3b3a5f7c31c2a0826.20200224163616GMT.87y2ss3ptr.fsf@bsb.me.uk Xref: csiph.com comp.lang.c:150197 Malcolm McLean writes: > On Saturday, 22 February 2020 18:38:59 UTC, already...@yahoo.com wrote: >> On Saturday, February 22, 2020 at 1:15:28 PM UTC+2, Malcolm McLean wrote: >> > Dust off your copy of Basic Algorithms and take the red black tree. >> > (The code used to be online but the provider has now gone defunct). >> >> Everything I read so far suggests (for me) that the optimal solution >> to James's task is some form of hash table rather than a tree. And >> if somehow I am wrong about it and the optimal solution is indeed a >> tree, it's a fat tree rather than a binary tree. >> > std::map is usually implemented as a red-black tree, and he specifically > mentioned that as acceptable. James did not say that implementing std::map is acceptable, only using it. The optimal solution takes into account the amount of work required to write the code, and a simple hash table seems to be way better than a red-black tree. You come over as simply pushing your self-published book. Why buy a book to implement red-black trees? -- Ben.