heapify( ) heapify()函数用于将一个序列转化为初始化堆 nums=[16,7,3,20,17,8,-1] print('nums:',nums) show_tree(nums) nums: [16, 7, 3, 20, 17, 8, -1] 16 7 3 20 17 8 -1 ------------------------------------ heapq.heapify(nums) print('nums:',nums) show_tree(nums) nums: [-1…