python计算最小优先级队列代码分享
复制代码 代码如下:# -*- coding: utf-8 -*- class Heap(object): @classmethod def parent(cls, i): “””父结点下标””” return int((i – 1) >> 1); @classmethod def left(cls, i): “””左儿子下标””” return (i << 1) + 1; @classmethod def right(cls, i): “””右儿子下标”””
用户评论