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


Groups > comp.lang.python > #102540

Re: _siftup and _siftdown 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: _siftup and _siftdown implementation
Date Fri, 5 Feb 2016 23:12:40 +0530
Lines 24
Message-ID <mailman.7.1454694210.2317.python-list@python.org> (permalink)
References <mailman.72.1454619005.30993.python-list@python.org> <56b3e902$0$1613$c3e8da3$5496439d@news.astraweb.com> <CACs7g=C-MEHLWYZWJPiiJfxoFHE3y3UcEL2Q7kE=HLNbGQkV+g@mail.gmail.com> <56B4CD7B.70506@mail.de>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de LXXKpk4YBe8v97137TMVFQgtMO9JDiPkwhhBqEYEq/yA==
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.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'value,': 0.03; 'true,': 0.04; '"""': 0.05; '(except': 0.05; 'pop': 0.05; '-*-': 0.07; '__name__': 0.07; 'filename:fname piece:py': 0.07; 'great.': 0.07; 'main()': 0.07; 'method,': 0.07; 'utf-8': 0.07; 'cc:addr:python-list': 0.09; '(0,': 0.09; '__all__': 0.09; '__future__': 0.09; 'blue': 0.09; 'coding:': 0.09; 'here?': 0.09; 'indexes': 0.09; 'inserted': 0.09; 'python': 0.10; 'files.': 0.13; 'index': 0.13; 'def': 0.13; '+91': 0.15; "'__main__':": 0.16; '(default=0)': 0.16; '-1):': 0.16; '2016': 0.16; '__lt__': 0.16; '__lt__(self,': 0.16; '__version__': 0.16; 'attaching': 0.16; 'happened?': 0.16; 'heap': 0.16; 'heapq': 0.16; 'item)': 0.16; 'item):': 0.16; 'item:': 0.16; 'iterable)': 0.16; 'key:': 0.16; 'len(self)': 0.16; 'main():': 0.16; 'peek': 0.16; 'pop(self,': 0.16; 'push(self,': 0.16; 'received:209.85.223.173': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'remove(self,': 0.16; 'reversing': 0.16; 'skip:{ 40': 0.16; 'sorting': 0.16; 'value))': 0.16; 'value:': 0.16; 'wow,': 0.16; 'wrote:': 0.16; 'student': 0.20; 'versions': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'otherwise,': 0.20; 'junior': 0.22; 'orientation': 0.22; "skip:' 40": 0.22; 'subject:skip:i 10': 0.22; 'pass': 0.22; 'code,': 0.23; 'feb': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'define': 0.27; 'fri,': 0.27; 'skip:# 10': 0.27; 'message-id:@mail.gmail.com': 0.27; 'cancel': 0.27; 'specify': 0.27; 'idea': 0.28; "skip:' 10": 0.28; 'skip:( 20': 0.28; '100000': 0.29; 'comparison': 0.29; 'index,': 0.29; 'key,': 0.29; 'other,': 0.29; "skip:' 50": 0.29; 'skip:k 30': 0.29; 'value)': 0.29; 'wraps': 0.29; 'raise': 0.29; 'random': 0.29; 'allows': 0.30; "i'm": 0.30; 'skip:_ 10': 0.32; 'useful': 0.33; 'class': 0.33; "skip:' 20": 0.34; 'received:google.com': 0.35; 'happened': 0.35; 'replace': 0.35; 'tasks': 0.35; 'something': 0.35; 'comment': 0.35; 'item': 0.35; 'supports': 0.35; 'but': 0.36; 'too': 0.36; 'skip:i 20': 0.36; 'lines': 0.36; 'received:209.85': 0.36; 'indian': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'charset:us-ascii': 0.37; 'received:209': 0.38; 'self': 0.38; 'several': 0.38; 'skip:p 20': 0.38; 'why': 0.39; 'test': 0.39; 'forget': 0.60; 'skip:u 10': 0.61; 'school': 0.62; 'providing': 0.62; 'skip:n 10': 0.62; 'strange': 0.63; 'different': 0.63; 'sounds': 0.76; '(3rd': 0.84; 'ph:': 0.84; 'remained': 0.84; 'x):': 0.84; 'items,': 0.91; 'benefits:': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=jQLsJ+cdlKReu3la5Axqv9AcULKGXL4pIcUEXs7VlHk=; b=o8tqWz5LXvx5h8CovdnFMFXO30CTzutgrp/wRHGjo8CSHZbaFBw+5vJsWH8HcL4dA3 kFWV4NMWu7zyQE4ar1C+TNxr7q6F6qTRlfDFLCCX4HG3D3qb/AE3wO9lv0djoY7AiuwV TGAyy17kN5QSkXnn5vWBVCsxfpDmsK5LZwm9OHYgejUtWJvHQez+mmSP7yr2C4ZjMVtO vuXJ/tBPWCmOdjxbnin3lK6lhHoCgoPsn+6lF1CkKqtjMfNwiW4JqnkXESUZhftGaQy8 m/GPi8QPOpCCxlLB2PExPmRi+v06AnR84QgkrBjjHUa7dk6X9xOSrkaSJoaIiyrO8M0V idWQ==
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:from:date :message-id:subject:to:cc:content-type; bh=jQLsJ+cdlKReu3la5Axqv9AcULKGXL4pIcUEXs7VlHk=; b=F0DfxQYu4zIJ8d8kLbCgP1fIUkFxnCSoHOFb55hmQZXt5JeVzynX42J1RWHwspomkk beC+lnf8F9M5G9J7I313ImUjqwSpLJAxR0Y6HYxXs75kbwYeI+LUCJSDpNTCgiSKwgYd QrYnwPfjgpJmrE4xxq99tK5ob2j18wzY1s5p5LnsmEjaFtVV309Lb9Bspq+jIK0Mduy5 quJUEoXbuU37zwkdKL4hI3ly8/HPs6gKM9+ulo1hQ8Xn6/NMwIozu1re52TIUOUCr0MZ WV7MJNRjH4h+0Cqovc5lKQ73BbPDy29ncsFLKetm1XZQpCRX417gRtueIUgNr0vy+LPB lVtw==
X-Gm-Message-State AG10YOR5M4ifl0yqJ8GLWReF3Z+rNCP7F3ZAD1EhMYG6R2280IUpTk0qVb20xd+mN9iErwCCSR0dqLCewNNATA==
X-Received by 10.107.41.206 with SMTP id p197mr16322197iop.80.1454694200391; Fri, 05 Feb 2016 09:43:20 -0800 (PST)
In-Reply-To <56B4CD7B.70506@mail.de>
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:102540

Show key headers only | View raw


wow, that's great.
you read a comment in the code, and you test it, to only find that it
is indeed true,
sounds ok, but feels great. :)

Just experimenting a bit, I swaped the lines _siftdown and _siftup and something
strange happened the number of comparisions in both the versions remained same.
I'm attaching the files.

do you have any idea why this happened?

On Fri, Feb 5, 2016 at 9:57 PM, Sven R. Kunze <srkunze@mail.de> wrote:
>
> Can we do better here?
>
I don't know, I have to read TAOP knuth article.

-- 
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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

_siftup and _siftdown implementation srinivas devaki <mr.eightnoteight@gmail.com> - 2016-02-05 02:20 +0530
  Re: _siftup and _siftdown implementation Steven D'Aprano <steve@pearwood.info> - 2016-02-05 11:12 +1100
    Re: _siftup and _siftdown implementation "Sven R. Kunze" <srkunze@mail.de> - 2016-02-05 01:21 +0100
    Re: _siftup and _siftdown implementation srinivas devaki <mr.eightnoteight@gmail.com> - 2016-02-05 06:56 +0530
    Re: _siftup and _siftdown implementation "Sven R. Kunze" <srkunze@mail.de> - 2016-02-05 15:42 +0100
    Re: _siftup and _siftdown implementation Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-02-05 12:48 -0200
    Re: _siftup and _siftdown implementation "Sven R. Kunze" <srkunze@mail.de> - 2016-02-05 15:55 +0100
    Re: _siftup and _siftdown implementation Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-02-05 12:59 -0200
    Re: _siftup and _siftdown implementation srinivas devaki <mr.eightnoteight@gmail.com> - 2016-02-05 21:15 +0530
    Re: _siftup and _siftdown implementation "Sven R. Kunze" <srkunze@mail.de> - 2016-02-05 17:27 +0100
    Re: _siftup and _siftdown implementation "Sven R. Kunze" <srkunze@mail.de> - 2016-02-05 17:35 +0100
    Re: _siftup and _siftdown implementation srinivas devaki <mr.eightnoteight@gmail.com> - 2016-02-05 23:12 +0530
    Re: _siftup and _siftdown implementation srinivas devaki <mr.eightnoteight@gmail.com> - 2016-02-06 20:16 +0530

csiph-web