概念回顧:
1、大頂堆:頭部為堆中最大的值
2、小頂堆:頭部為隊中最小的值
3、PriorityQueue:一個具有優先級的隊列,該優先級使得隊列始終按照自然順序進行排序,隊列的頭部為最小值。
構造小頂堆:
PriorityQueue small=new PriorityQueue<>();
構造大頂堆:
PriorityQueue small=new PriorityQueue<>(Collections.reverseOrder());
1、大頂堆:頭部為堆中最大的值
2、小頂堆:頭部為隊中最小的值
3、PriorityQueue:一個具有優先級的隊列,該優先級使得隊列始終按照自然順序進行排序,隊列的頭部為最小值。
PriorityQueue small=new PriorityQueue<>();
PriorityQueue small=new PriorityQueue<>(Collections.reverseOrder());