Numerically largest entry in a trie of digits

Gregor Mückl gregormueckl at gmx.de
Wed Apr 20 07:14:36 UTC 2022


On Tuesday, 19 April 2022 at 16:35:21 UTC, H. S. Teoh wrote:
> Just thought I'd pick all the bright minds here: I have a set 
> of numbers in string form (as decimal digits), stored in a 
> trie.  How do I retrieve the largest number in the set?
>

Just to get the dumb answer out of the way: we need to assume 
that the trie is updated dynamically, right? So just trivially 
taking the maximum while inserting all the members won't work.

In the dynamic case, keeping a separate sorted list sounds best 
if memory usage is of no concern to you. If you really need only 
the largest value and performance is a concern, a max heap would 
probably be faster than a fully sorted list.


More information about the Digitalmars-d mailing list