2. COURSE LEARNING
OUTCOMES:
1. Familiarize Priority Queues and Heap
Tree
2. Know the basic operations on Binary
heap Tree
3. Know to insert a new and delete heap
tree node
4. A priority queue is
a special type of
queue in which each
element is associated with
a priority value. And,
elements are served on
the basis of their priority.
That is, higher priority
elements are served first.
PRIORIT
Y QUEUE
A priority queue is a type of
queue that arranges
elements based on their
priority values.
8. • insert / enqueue − add an
item to the rear of the queue.
• remove / dequeue −
remove an item from the
front of the queue.
Basic
Operatio
ns
9. • Peek − Retrieves, but
does not remove, the
head of this queue, or
returns null if this queue
is empty.
• isFull − check if queue
is full.
• isEmpty − check if
queue is empty.
Metho
d
• Poll − retrieves and
removes the head of this
queue, or returns null if
this queue is empty.
10. A priority queue is
typically implemented
using heap data
structure.
Where is priority
queue used ?
Is Priority
Queue sorted?
The elements of the priority queue
are ordered according to their
natural ordering, or by a comparator
provided at queue construction
time, depending on which
constructor is used.
A priority Queue does not permit
null elements.
11. A heap is a specific tree-
based data structure in
which all the nodes of
tree are in a specific
order.
HEAP
TREE
A heap is a complete
binary tree structure
where each element
satisfies a heap
property.
12.
13. Identify the following either
it is a complete binary tree
or not.
Answer Y for yes or N for
no
Drill
15. In a Min-Heap the key present at the root
node must be less than or equal among
the keys present at all of its children
2 types of
heap
In a Max-Heap the key present at the root
node must be greater than or equal
among the keys present at all of its
children.
16. Get ½ Crosswise and
convert the following using
Max and Min Heap
ANSWER