From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Udyant Wig Newsgroups: gmane.emacs.help Subject: Re: Most used words in current buffer Date: Mon, 23 Jul 2018 12:56:34 +0530 Organization: A noiseless patient Spider Message-ID: References: <861sc1iu1m.fsf@zoho.com> <87pnzkcgna.fsf@bsb.me.uk> <20180722090242.GA8678@tuxteam.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1532330911 25986 195.159.176.226 (23 Jul 2018 07:28:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 23 Jul 2018 07:28:31 +0000 (UTC) Injection-Date: Mon, 23 Jul 2018 07:26:37 -0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 23 09:28:26 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fhVGc-0006dO-CH for geh-help-gnu-emacs@m.gmane.org; Mon, 23 Jul 2018 09:28:26 +0200 Original-Received: from localhost ([::1]:33136 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhVIj-0005GU-3J for geh-help-gnu-emacs@m.gmane.org; Mon, 23 Jul 2018 03:30:37 -0400 X-Received: by 2002:a1c:f405:: with SMTP id z5-v6mr1191852wma.1.1532330797650; Mon, 23 Jul 2018 00:26:37 -0700 (PDT) Original-Path: usenet.stanford.edu!o2-v6no21102wmc.0!news-out.google.com!d15-v6ni80wmb.0!nntp.google.com!proxad.net!feeder1-2.proxad.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 51 Original-Injection-Info: reader02.eternal-september.org; posting-host="c5d00cdbb3f2e2fdcc778adb0b9a1341"; logging-data="13053"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18eRnhYEVtnKBk1JiLxNz+u" Cancel-Lock: sha1:qRIub0mWIrpHcnzQTmZ89VIFE8A= In-Reply-To: Openpgp: preference=signencrypt Content-Language: en-US Original-Xref: usenet.stanford.edu gnu.emacs.help:223445 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:117570 Archived-At: On 07/23/2018 11:39 AM, Bob Proulx wrote: > tomas@tuxteam.de wrote: >> Stefan Monnier wrote: >>> I'd use a hash-table (implemented in C) rather than an avl-tree >>> (implemented in Elisp). > > With exactly those choices above I would agree completely. Would you choose differently if Emacs had a native code compiler besides a byte code one? >> Plus, a (well-implemented) hash table will always be faster (for >> inserts and random lookups) than a balanced (AVL, red-black) binary >> tree. The latter affords you sorted lookup (find first greater than, >> output in order). >> >> You pay for that :-) > > Again the hash table is good until you need to grow the table. Then > there is a pause while memory is shuffled around. But that never > happens with a balanced tree because that cost is always amortized > along as you go. Yes. > Also if you need to extract the entries in sorted order then the > balanced tree is already sorted. Whereas with the hash table an extra > sort step is needed. It just occured to me that when I obtain a list of the elements of the AVL tree solution, I get a sorted list, though in ascending order. After this, I sort to get the list in descending order. I could have avoided this silly sorting and simply reversed the list. > One of looking at this is that it is global optimization versus local > optimization. > > In some ways it is swings and roundabouts. But in other ways it > depends upon what you need. Which might entail more swings and roundabouts. > Bob Udyant Wig -- We make our discoveries through our mistakes: we watch one another's success: and where there is freedom to experiment there is hope to improve. -- Arthur Quiller-Couch