Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102700

Re: Heap Implementation

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: Heap Implementation
Date Tue, 9 Feb 2016 08:42:12 +0530
Lines 43
Message-ID <mailman.117.1454987536.2317.python-list@python.org> (permalink)
References <56AD3D83.2050308@mail.de> <7C522D08-9D73-48D2-A71D-F1D1D34C02A5@gmail.com> <CACs7g=Cu=tGhU3TtBa0cYr46WP7kOHWyxz2TiHXCuiSLqb4P7A@mail.gmail.com> <185DAEA4-8728-4792-A3B7-7F6AC5A7F876@gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de hdXstf0EyBYyWZkqjAyx0Qr318yUmRbntYEN79HpEAcQ==
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.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'feature.': 0.07; 'cc:addr:python-list': 0.09; 'dict': 0.09; 'subclass': 0.09; 'times,': 0.13; '+91': 0.15; 'argument': 0.15; '10:15': 0.16; '2016': 0.16; '7:07': 0.16; 'distinct': 0.16; 'heap': 0.16; 'keys.': 0.16; 'pairs': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'side.': 0.16; 'structure.': 0.16; 'wrote:': 0.16; 'duplicate': 0.18; 'library,': 0.18; '&gt;': 0.18; 'email addr:gmail.com&gt;': 0.18; 'library': 0.20; 'student': 0.20; 'cc:addr:python.org': 0.20; 'proposed': 0.20; 'cc:2**1': 0.22; 'meant': 0.22; 'junior': 0.22; 'am,': 0.23; 'feb': 0.23; 'insert': 0.23; 'header:In-Reply-To:1': 0.24; 'feature': 0.24; "doesn't": 0.26; 'handling': 0.27; 'separate': 0.27; 'message- id:@mail.gmail.com': 0.27; 'idea': 0.28; 'directly,': 0.29; 'fast.': 0.29; 'queue': 0.29; "i'm": 0.30; 'another': 0.32; 'useful': 0.33; 'instances': 0.33; 'items.': 0.33; 'handle': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'library.': 0.35; 'asking': 0.35; 'item': 0.35; 'but': 0.36; 'too': 0.36; 'should': 0.36; 'instead': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'indian': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'client': 0.37; 'received:209': 0.38; 'data': 0.39; 'easily': 0.39; 'well.': 0.40; 'still': 0.40; 'your': 0.60; 'provide': 0.61; 'school': 0.62; 'providing': 0.62; 'different': 0.63; 'introduce': 0.79; '(3rd': 0.84; 'client-side': 0.84; 'dict,': 0.84; 'ph:': 0.84; 'priorities,': 0.84
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=a5U25XZm8fbMODHi8NK7GPH58xTx+oFK6mWebuGYCvs=; b=YRAejmJDW3QfnXJUHpxMBlGNex9NU+QdcdL0jE+lStfrNbV1cwbdDiZolSsqTLgh3a N0GNXs1of0iiZeTY1ZGrlByKQdi8NUlmOdqfCwhRerOXsd8KzDFLn9P8hbuyBj82mt04 T7ewaGGpddIDl82BclfLBtRMElk5NQKcOaKWV/1YhFRSd5YKGECpx9frpx2hsehtpEtO cBgJ4dwlVjTuvbsrXuGQyYye9Ycy3FMx4v+O0lpM3Xi7ATaUfNwvO8oCPtKrWH8lc8d0 WyhDem6a7KZP+gdFU1NK1O4gdpgP1Rr/h6/kOsHqS0femc7LN6OQzX6HyGF1bF325oBT yNfQ==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=a5U25XZm8fbMODHi8NK7GPH58xTx+oFK6mWebuGYCvs=; b=XG2YyamMGH0Iz/84iF7w+Xd/pVqsg9tQ2Z0RkVKhEH/EaAeqPYixc692nWOheoBMMW UiYcKLNrfx55bOHOZU/Uz7gZutIJatLJzuxC3tqyHf1adYISNjh9FlLhu2jb45jwHYWz pN8f55JfBEca1LyjuJEmbXjLMzgHwsMcajnLN9p9R8B1QBDdDInTAJ2HUBJCTeOR/VU4 zJS1OHPljm/d3IPeBFw0rzZylqrORqUgeV5JydkyVv7UBzbwVvVvsruknQUZlwvurpf4 71hQShLEpRbcqZlrFC280wsUZIP7sE7Zqsrdbe8QC2smQgpe4HaXANU1os6jIV27keGR Xo4Q==
X-Gm-Message-State AG10YOTC8l1Fosx61kCTQqFLCWBuJ0BnxnJ0bGDb9H0l9v1/h2e2oMtugJEcvAPZ4OlTrwH79UlbRCq8luviCA==
X-Received by 10.107.135.30 with SMTP id j30mr36307269iod.103.1454987533762; Mon, 08 Feb 2016 19:12:13 -0800 (PST)
In-Reply-To <185DAEA4-8728-4792-A3B7-7F6AC5A7F876@gmail.com>
X-Content-Filtered-By Mailman/MimeDel 2.1.21rc2
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21rc2
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:102700

Show key headers only | View raw


On Feb 8, 2016 5:17 PM, "Cem Karan" <cfkaran2@gmail.com> wrote:
>
> On Feb 7, 2016, at 10:15 PM, srinivas devaki <mr.eightnoteight@gmail.com>
wrote:
> > On Feb 8, 2016 7:07 AM, "Cem Karan" <cfkaran2@gmail.com> wrote:
> > > I know that there are methods of handling this from the client-side
(tuples with unique counters come to mind), but if your library can handle
it directly, then that could be useful to others as well.
> >
> > yeah it is a good idea to do at client side.
> > but if it should be introduced as feature into the library, instead of
tuples, we should just piggyback a single counter it to the self._indexes
dict, or better make another self._counts dict which will be light and fast.
> > and if you think again with this method you can easily subclass with
just using self._counts dict  in your subclass. but still I think it is
good to introduce it as a feature in the library.
> >
> > Regards
> > Srinivas Devaki
>
> I meant that the counter is a trick to separate different instances of
(item, priority) pairs when you're pushing in the same item multiple times,
but with different priorities.

oh okay, I'm way too off.

what you are asking for is a Priority Queue like feature.

but the emphasis is on providing extra features to heap data structure.

and xheap doesn't support having duplicate items.

and if you want to insert same items with distinct priorities, you can
provide the priority with key argument to the xheap. what xheap doesn't
support is having same keys/priorities.
So I got confused and proposed a method to have same keys.

Regards
Srinivas Devaki
Junior (3rd yr) student at Indian School of Mines,(IIT Dhanbad)
Computer Science and Engineering Department
ph: +91 9491 383 249
telegram_id: @eightnoteight

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Heap Implementation srinivas devaki <mr.eightnoteight@gmail.com> - 2016-02-09 08:42 +0530

csiph-web