# 二叉堆的基本原理

Binary Heap isn't mysterious; its properties are even simpler than those of a Binary Search Tree.

The primary operations of a Binary Heap are `sink`

(downward movement) and `swim`

(upward movement), which help maintain the properties of the binary heap.

There are two main applications of a Binary Heap: first, as a very useful data structure called a Priority Queue, and second, as a sorting method known as Heap Sort.

This visualization panel intuitively demonstrates the basic operations of a Binary Heap. You can click to execute the code or modify it yourself for experimentation:

Now, let's use the visualization panel to explain the principles of a Binary Heap. Finally, we'll show the code implementation of a Binary Heap using a priority queue as an example.