mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-19 03:55:50 +08:00
Update codes of heap.java and my_heap.java
This commit is contained in:
@ -105,10 +105,16 @@ public class PrintUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void printHeap(PriorityQueue<Integer> queue) {
|
||||
Integer[] nums = (Integer[])queue.toArray();
|
||||
TreeNode root = TreeNode.arrToTree(nums);
|
||||
|
||||
/**
|
||||
* Print a heap (PriorityQueue)
|
||||
* @param queue
|
||||
*/
|
||||
public static void printHeap(Queue<Integer> queue) {
|
||||
List<Integer> list = new ArrayList<>(queue);
|
||||
System.out.print("堆的数组表示:");
|
||||
System.out.println(list);
|
||||
System.out.println("堆的树状表示:");
|
||||
TreeNode root = TreeNode.listToTree(list);
|
||||
printTree(root);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user