< Nafees />
github
  • Assignments - DSA
  • Long Integer Operations
  • OOP
    • Introduction
    • Implementation
  • Sorting Algorithms
    • Selection Sort
    • Bubble Sort
    • Insertion Sort
    • Shell Sort
    • Shuffle
    • Merge Sort
    • Convex Hull
    • Quick sort
    • System Sort
    • Heap-Sort
  • Binary Search
  • Binary Search By Recursion
  • Two-Pointer
  • String
  • LeetCode 75
    • Array/String
    • Hash Map
    • BST
    • Binary Search
  • Top Interview 150
    • Linked-List
  • Leetcode Programming Skill
    • Math
  • Leetcode 75
  • 🤡Leet Code Extra
  • Arrays
    • 1-D Array
    • 2-D Arrays
  • 👨‍🍳Basic Math - Codechef
  • ☠️Recursion
  • 😁Public Member Functions
    • Strings Functions
  • 👾Linked List
    • What's Linked List & Implementation?
      • Singly Linked List
      • Doubly Linked List
    • Problems
  • 📚Stack
    • What's Stack & Implementation?
      • Stack Using Array
      • Stack using LL
    • Problems
  • 🏧Queue
    • What's Queue & Implementation?
      • Simple Queue
      • Queue using LL
      • Circular Queue
      • Deque using Linked List
      • STL Deque
    • Problems
  • 🏧Priority Queue
    • What's Priority Queue & Implementation
      • OrderedArrayMaxPQ.Java
      • Maximum-Oriented PQ using Binary Heap
      • Minimum-Oriented PQ using Binary Heap
    • Problems
  • 🗓️Hash Table
    • What's Hash Table & Implementation
      • ST - Seperate Chaining
      • ST - Linear Probing
    • Problems
  • 🎴Symbol Table
    • What's Symbol Table and implementation
      • ST Using Binary search (ordered array)
      • ST Using Binary Search Tree
      • ST Using Left-Leaning Red-Black Tree
      • ST Using Hash Table
    • Problems
  • 🔗Union-Find (Dynamic Connectivity problem)
    • What is a Union Find Data Structure?
    • Implementation
  • 🎋Binary Tree
    • What's Binary Tree & Implementation?
      • Traversal
      • Red-Black BST
  • 🌴Trie
    • What's Trie & Implementation?
    • Problems
  • 😎Project
    • Expression Evaluation
Powered by GitBook
On this page
  • Priority Queue Applications
  • Priority queue client example
  • Exercise

Was this helpful?

  1. Priority Queue

What's Priority Queue & Implementation

A priority queue is a special type of queue in data structure where each element is associated with a priority.

PreviousProblemsNextOrderedArrayMaxPQ.Java

Last updated 10 months ago

Was this helpful?

Randomized queue. Remove a random item.

Priority queue. Remove the largest (or smallest) item.

operation
arguments
return value

insert

P

insert

Q

insert

E

remove max

Q

insert

X

insert

A

insert

M

remove max

X

insert

P

insert

L

insert

E

remove max

P

Priority Queue Applications

  • Event-driven simulation. [customers in a line, colliding particles]

  • Numerical computation. [reducing roundoff error]

  • Data compression. [Huffman codes]

  • Graph searching. [Dijkstra's algorithm, Prim's algorithm]

  • Number theory. [sum of powers]

  • Artificial intelligence. [A* search]

  • Statistics. [maintain largest M values in a sequence]

  • Operating systems. [load balancing, interrupt handling]

  • Discrete optimization. [bin packing, scheduling]

  • Spam filtering. [Bayesian spam filter]

Priority queue client example

Challenge Find the largest M items in a stream of N items. [N huge, M large]

・Fraud detection: isolate $$ transactions.

・File maintenance: find the biggest files or directories.

Constraint Not enough memory to store N items.

Slides # 6, 7, 8

Exercise
🏧
5MB
PriorityQueues.pdf
pdf
Page cover image