Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101483
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | srinivas devaki <mr.eightnoteight@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: How to remove item from heap efficiently? |
| Date | Mon, 11 Jan 2016 20:23:44 +0530 |
| Lines | 18 |
| Message-ID | <mailman.16.1452524028.13488.python-list@python.org> (permalink) |
| References | <568EEC40.7070807@mail.de> <CACs7g=Bjccja67M3t4yL+07vO8iAcOB-dF5p2PgqqBwjFmbh=w@mail.gmail.com> <568FE797.6090808@mail.de> <CACs7g=CE7y-aXSdWbN7Fk0J4O4aRwAH5ad7UR1Jhdf9EpNFnug@mail.gmail.com> <5692A795.3070904@mail.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de tqBsprS/bYQQMdYLMWKuQgWxjiG9AP1W6+n2rJL12snQ== |
| Return-Path | <mr.eightnoteight@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'subject:How': 0.09; 'jan': 0.11; '2016': 0.16; 'amortized': 0.16; 'heap': 0.16; 'o(len(heap))': 0.16; 'operation.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:item': 0.16; 'subject:remove': 0.16; 'useless': 0.16; 'wrote:': 0.16; '>': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'cc:no real name:2**0': 0.22; 'am,': 0.23; 'split': 0.23; 'header:In- Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'operations,': 0.27; 'that.': 0.30; 'becomes': 0.30; 'checks': 0.30; 'items.': 0.33; 'add': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'done': 0.35; 'received:209.85': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'thanks': 0.37; 'received:209.85.213': 0.37; 'doing': 0.38; 'received:209': 0.38; 'means': 0.39; 'subject:from': 0.39; 'more': 0.63; 'our': 0.64; 'complexity': 0.84; 'approached': 0.95 |
| 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=1CGSPt6bPPccXRjdsf6qheELBSXxp6GD941xFn6HFHc=; b=k3KdBIxeOh8QhlWceIijMqSLG07uh4kcc5OsiCRqd96PanxN0GtEvfryF43Dp62Zmq S/drPIOhFpztCX1y31T6tcngeO7ZhcTUxGdFWwewpgdzsciaSby3OKE7IbDWcO90eNOk /3KEJ+xdinLF98WCD5+JTAEHx6oQFbxv8k3YYLAbUJxvVyeAbzzls5oVIJEOiaCKTV/v 6g1K+MGTTYEYeRKg7wbQAIFvO0iPuCTOWbJ10erQAkcrV57nwt1+Axsu0gGG4fnVjuDK cG9bvD9RDhcx95s+tJKdXNkA1yLKSErxouOgeKjTmjgy195hSq1CKjTD1ByQrci718ui s81A== |
| X-Received | by 10.50.79.167 with SMTP id k7mr4393783igx.41.1452524025536; Mon, 11 Jan 2016 06:53:45 -0800 (PST) |
| In-Reply-To | <5692A795.3070904@mail.de> |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.20+ |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:101483 |
Show key headers only | View raw
On Jan 11, 2016 12:18 AM, "Sven R. Kunze" <srkunze@mail.de> wrote: > Indeed. I already do the sweep method as you suggested. ;) > > Additionally, you provided me with a reasonable condition when to do the sweep in order to achieve O(log n). Thanks much for that. I currently used a time-bases approached (sweep each 20 iterations). > > PS: Could you add a note on how you got to the condition ( 2*self.useless_b > len(self.heap_b))? > oh that's actually simple, that condition checks if more than half of heap is useless items. the sweep complexity is O(len(heap)), so to keep the extra amortized complexity as O(1), we have to split that work(virtually) with O(len(heap)) operations, so when our condition becomes true we have done len(heap) operations, so doing a sweep at that time means we splitted that work(O(len(heap))) with every operation.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How to remove item from heap efficiently? srinivas devaki <mr.eightnoteight@gmail.com> - 2016-01-11 20:23 +0530
csiph-web