Skip to content

算法练习: 优先队列和堆(Priority Queue & Heap) #25

Description

@ShannonChenCHN

优先队列

A priority queue is a queue where the most important element is always at the front.

The queue can be a max-priority queue (largest element first) or a min-priority queue (smallest element first).

参考:

题目列表

总结

  1. 需要掌握的基础知识有:
    • 什么是堆
      • 完全二叉树
      • 父比子大/小
    • 如何实现一个堆
      • 存储:一般是数组
      • 操作:insert、remove、shiftUp、shiftDown
    • 堆排序:建堆+排序
  2. 遇到求 Top K 或者第 K 大的数这类问题时,都可以考虑是否用堆来实现
  3. 重点掌握建堆的模板代码

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions