Answers for "what is use of heap"

6

heap in java

In Java PriorityQueue can be used as a Heap.

Min Heap
PriorityQueue<Integer> minHeap = new PriorityQueue<>();


Max Heap:
PriorityQueue<Integer> maxHeap = new PriorityQueue<>(Comparator.reverseOrder());
Posted by: Guest on August-31-2020
1

example of a min heap

10                      10
         /      \               /       \  
       20        100          15         30  
      /                      /  \        /  \
    30                     40    50    100   40
Posted by: Guest on May-29-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language