Searching and Sorting II Flashcards
(4 cards)
1
Q
What is a queue ?
A
First in First Out
2
Q
What is a Priority Queue ?
A
Each element has a priority,
Dequeue removes the highest priority item, not the oldest,
if priorities match, normal fifo
3
Q
What is a heap ?
A
A complete binary tree represented as an array,
Max-heap - Every parent node is greater than or equal to its children,
Min-heap - Every parent node is less than or euqal to its children.
4
Q
What are the steps of a HeapSort algorithm ?
A
- Build a max heap from the array,
- Swap the root (largest) with the last element,
- Reduce the heap size and call Max_Heapify on the root,
- repeat until the array is sorted.