Heaps

less than 1 minute read

Heap as a Priority Queue in java

Heaps (Priority Queues in Java)

Heaps are represented using Priority Queue.

  • It gives O(1) seek time.
  • Does not permit null elements.
  • The elements are ordered according to their natural ordering, or by a Comparator provided at queue construction time.

METOHDS :

  • add(E e) Inserts the specified element into this priority queue.
  • offer(E e) Inserts the specified element into this priority queue
  • poll()Retrieves and removes the head of this queue, or returns null if this queue is empty.