13 Priority Queues Sorting Flashcards
Priority Queue
A data structure for maintaing a set of elements, each with an associated value called a key.
A max-priority queue supports the following operations:
INSERT - Inserts a new element into the set.
EXTRACT-MAX - removes and returns the element with the largest key.
INCREASE-KEY - increases the value of element key to the new value which is assummed to be at least as largest as currency key value.
Priority Queues Operations Running times:
O(log n)
MAX-HEAPIFY Running Time
O(log n)
BUILD MAX-HEAP Running Time
O(n)
HEAP-SORT
O(n log n)
Insertion Sort
A variation of priority queue sorting where the priority queue is implemented with a sorted array.
O(n^2)
Selection Sort
A variation of priority queue sorting where the priority queue is implemented with a unsorted array.
O(n^2)
Heapsort
A variation of priority queue sorting where the priority queue is implemented with a binary heap.
n insertions takes O(n) time
n removals take O(n log n) time