摘要: a=[5,4,2,3,1]print(a)n=len(a)l=0r=n-1while True: if a[l]>a[r]: a[l],a[r]=a[r],a[l] r=r-1 if l==r: l=l+1 ... 阅读全文
posted @ 2018-06-27 11:47 luoganttcc 阅读(78) 评论(0) 推荐(0) 编辑
摘要: import heapq#-*- coding: UTF-8 -*-import numpy as npdef MakeHeap(a): for i in range(int(a.size / 2) - 1, -1, -1):#对非叶子节点的子节点进行... 阅读全文
posted @ 2018-06-27 10:43 luoganttcc 阅读(135) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python3# -*- coding: utf-8 -*-"""Created on Tue Jun 26 22:32:27 2018@author: luogan"""class Node(object): def _... 阅读全文
posted @ 2018-06-27 09:49 luoganttcc 阅读(303) 评论(0) 推荐(0) 编辑