Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.028 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'table.': 0.07; 'dan': 0.09; 'cc:addr:python-list': 0.11; 'bucket': 0.16; 'cc:name:python list': 0.16; 'size;': 0.16; 'tends': 0.16; 'vanishingly': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'fixed': 0.29; 'array': 0.29; 'needed.': 0.30; 'message- id:@mail.gmail.com': 0.30; 'getting': 0.31; 'becomes': 0.33; 'table': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'list.': 0.37; 'pm,': 0.38; 'itself': 0.39; 'enough': 0.39; 'full': 0.61; 'more': 0.64; 'linked': 0.65; 'mar': 0.68; 'grow': 0.77 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=teQPb/rpLcWeX5KWenqs/XEpXDVy6g/Q6HeVaL5QeOU=; b=WcZWbHpDeMr8oTsKDev58GWNbe/LD46vLZqgULDZZIsJ29H0X/SwM9hIe+VcwGDSp/ GbcAATy65aws0dWu9aTqSMUFVcnYJsfOOzztEFM13Nydi9N1cUFvwRWurIR1aHm49lT7 QX7xKpOMAREIoSdTqW2bN1BvSlEUcEAvEBPPwklBlNwuLJ1akD2m+8IEnWEkkNMIszUz OyCF/OzFuT3eVASBGK4tK9f7V1OuDh62SJPpVRDoBlam2j61QJsNlgigKdyblGuCRaPA 9A6XPAHaihuQvhyYf0A+r9tXwwzyKHVnqZmf3XaCdewA9N8GQUUG/jaSxWT+FR9+lfKh 1YUg== MIME-Version: 1.0 X-Received: by 10.236.16.83 with SMTP id g59mr40856883yhg.14.1394402900390; Sun, 09 Mar 2014 15:08:20 -0700 (PDT) In-Reply-To: <8761nnrqsk.fsf@elektro.pacujo.net> References: <87eh2d3x8h.fsf_-_@elektro.pacujo.net> <87eh2ctmht.fsf@elektro.pacujo.net> <87zjkz3eo3.fsf@elektro.pacujo.net> <87a9czrrax.fsf@elektro.pacujo.net> <8761nnrqsk.fsf@elektro.pacujo.net> Date: Sun, 9 Mar 2014 15:08:20 -0700 Subject: Re: Balanced trees From: Dan Stromberg To: Marko Rauhamaa Content-Type: text/plain; charset=ISO-8859-1 Cc: Python List X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394402908 news.xs4all.nl 2854 [2001:888:2000:d::a6]:40858 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68098 On Sun, Mar 9, 2014 at 2:43 PM, Marko Rauhamaa wrote: > Dan Stromberg : > >> On Sun, Mar 9, 2014 at 2:32 PM, Marko Rauhamaa wrote: >>> There is no O(1) hash table. >> >> http://stackoverflow.com/questions/2771368/can-hash-tables-really-be-o1 > > Please elaborate. A hash table of fixed size is O(1) until you fill it so full that you start getting enough collisions to make it O(n), as one bucket becomes a linked list. This is because the hash function is O(1), and looking up a value in a C array is O(1). A more flexible hash table will not have a fixed size; instead it will grow itself as needed. This growth operation tends to be O(n), but happens vanishingly infrequently as the table grows, so it's still amortized O(1).