Searching and Sorting II Flashcards

(4 cards)

1
Q

What is a queue ?

A

First in First Out

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the steps of a HeapSort algorithm ?

A
  1. Build a max heap from the array,
  2. Swap the root (largest) with the last element,
  3. Reduce the heap size and call Max_Heapify on the root,
  4. repeat until the array is sorted.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly