# 21 - Binomial Heaps Data Structures and Algorithms Andrei...

This preview shows pages 1–7. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Binomial Heaps Data Structures and Algorithms Andrei Bulatov Algorithms – Binomial Heaps 21-2 Priority Queues • Supports the following operations. – Insert element x. – Return min element. – Return and delete minimum element. ecrease key of element x to k – Decrease key of element x to k . • Applications. – Dijkstra's shortest path algorithm. – Prim's MST algorithm. – Event-driven simulation. – Huffman encoding. – Heapsort. – . . . Algorithms – Binomial Heaps 21-3 Dijkstra’s Algorithm set S:={s} and d(s):=0 while S ≠ V do pick a node v not from S such that the value s minimal )} ( ) ( { min : ) ( ' ), , ( e len u d v d S u v u e + = ∈ = is minimal set S:=S ∪ {v}, and d(v):=d’(v) endwhile Algorithms – Binomial Heaps 21-4 Dijkstra’s Algorithm: PQ Style call PQinit set S:=V set key(s):=0 PQinsert(s) for each v ∈ V-{s} key(v):= ∞ call PQinsert(v) while not PQisempty set v:=Pqdelmin set S:=S-{v} for each w ∈ Q such that (v,w) ∈ E if key(w)>key(v)+len(v,w) then call PQdecrease(w,key(v)+len(v,w)) Algorithms – Binomial Heaps 21-5 Priority Queues make-heap Operation insert find-min elete in 1 Binary log N 1 g N 1 Binomial log N log N g N 1 Fibonacci * 1 1 g N 1 Relaxed 1 1 g N 1 Linked List 1 N Heaps Dijkstra/Prim 1 make-heap |V| insert |V| delete-min |E| decrease-key delete-min union decrease-key delete log N N log N log N log N log N log N log N log N 1 1 log N log N 1 1 log N N 1 1 N is-empty 1 1 1 1 1 O(|E| + |V| log |V|) O(|E| log |V|) O(|V| 2 ) Algorithms – Binomial Heaps 21-6 Binomial Tree Recursive definition:- B is a single node...
View Full Document

## This note was uploaded on 11/19/2009 for the course CS CMPT 307 taught by Professor A.bulatov during the Fall '09 term at Simon Fraser.

### Page1 / 25

21 - Binomial Heaps Data Structures and Algorithms Andrei...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online