Priority Queues and Heaps_Part_8

# Priority Queues and Heaps_Part_8 - Last Updated: 06/02/12...

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

Last Updated: 06/02/12 8:32 PM CSE 2011 Prof. J. Elder - 36 - Example Operation Output P insert( 5 , A ) e 1 ( 5 , A ) insert( 3 , B ) e 2 ( 3 , B ) , ( 5 , A ) insert( 7 , C ) e 3 ( 3 , B ) , ( 5 , A ) , ( 7 , C ) min() e 2 ( 3 , B ) , ( 5 , A ) , ( 7 , C ) key( e 2 ) 3 ( 3 , B ) , ( 5 , A ) , ( 7 , C ) remove( e 1 ) e 1 ( 3 , B ) , ( 7 , C) replaceKey( e 2 , 9 ) 3 ( 7 , C ) , ( 9 , B ) replaceValue( e 3 , D ) C ( 7 , D ) , ( 9 , B ) remove( e 2 ) e 2 ( 7 , D )

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

View Full Document
Last Updated: 06/02/12 8:32 PM CSE 2011 Prof. J. Elder - 37 - Locating Entries In order to implement the operations remove(k), replaceKey(e), and replaceValue(k), we need fast ways of locating an entry e in a priority queue. We can always just search the entire data structure to find an entry e, but there are better ways for locating entries.
Last Updated: 06/02/12 8:32 PM CSE 2011 Prof. J. Elder - 38 - Location-Aware Entries A location-aware entry identifies and tracks the location of its (key, value) object within a data structure

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: Last Updated: 06/02/12 8:32 PM CSE 2011 Prof. J. Elder - 39 - List Implementation A location-aware list entry is an object storing key value position (or rank) of the item in the list In turn, the position (or array cell) stores the entry Back pointers (or ranks) are updated during swaps trailer header nodes/positions entries 2 c 4 a 5 d 8 b Last Updated: 06/02/12 8:32 PM CSE 2011 Prof. J. Elder - 40 - Heap Implementation A location-aware heap entry is an object storing key value position of the entry in the underlying heap In turn, each heap position stores an entry Back pointers are updated during entry swaps 4 a 2 d 6 b 8 g 5 e 9 c...
View Full Document

## This note was uploaded on 02/14/2012 for the course CSE 2011Z taught by Professor Elder during the Fall '11 term at York University.

### Page1 / 5

Priority Queues and Heaps_Part_8 - Last Updated: 06/02/12...

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

View Full Document
Ask a homework question - tutors are online