Locators 3 a 1 g 4 e 12/29/2018 7:56 AM Locators Locators

Slides:



Advertisements
Similar presentations
Heaps1 Part-D2 Heaps Heaps2 Recall Priority Queue ADT (§ 7.1.3) A priority queue stores a collection of entries Each entry is a pair (key, value)
Advertisements

Priority Queues. Container of elements where each element has an associated key A key is an attribute that can identify rank or weight of an element Examples.
© 2004 Goodrich, Tamassia Binary Search Trees   
Binary Search Trees1 Part-F1 Binary Search Trees   
Chapter 8: Priority Queues
Priority Queues. Container of elements where each element has an associated key A key is an attribute that can identify rank or weight of an element Examples.
Chapter 8: Priority Queues and Heaps Nancy Amato Parasol Lab, Dept. CSE, Texas A&M University Acknowledgement: These slides are adapted from slides provided.
Adaptable Priority Queues1 3 a 5 g 4 e © 2010 Goodrich, Tamassia.
For Monday Read Weiss, chapter 7, sections 1-3. Homework –Weiss, chapter 4, exercise 6. Make sure you include parentheses where appropriate.
CSC401 – Analysis of Algorithms Lecture Notes 6 Dictionaries and Search Trees Objectives: Introduce dictionaries and its diverse implementations Introduce.
Priority Queues and Heaps. Outline and Reading PriorityQueue ADT (§8.1) Total order relation (§8.1.1) Comparator ADT (§8.1.2) Sorting with a Priority.
CH 8. HEAPS AND PRIORITY QUEUES ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA.
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
Heap Sorting and Building
Priority Queues Last Update: Oct 23, 2014 EECS2011: Priority Queues1.
Adaptable Priority Queues1 3 a 5 g 4 e © 2013 Goodrich, Tamassia, Goldwasser.
1 Heaps II Implementation HeapSort Bottom-Up Heap Construction Locators.
1 COMP9024: Data Structures and Algorithms Week Seven: Priority Queues Hui Wu Session 1, 2016
Adaptable Priority Queues1 3 a 5 g 4 e © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java,
Partially Ordered Data ,Heap,Binary Heap
Priority Queues 5/3/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
Priority Queue A Priority Queue Set S is made up of n elements: x0 x1 x2 x3 … xn-1 Functions: createEmptySet() returns a newly created empty priority.
Fundamentals of Programming II Overview of Collections
Top 50 Data Structures Interview Questions
CS 315 Data Structures B. Ravikumar Office: 116 I Darwin Hall Phone:
Priority Queues © 2010 Goodrich, Tamassia Priority Queues 1
Heaps 8/2/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser,
Priority Queues Chuan-Ming Liu
Programming Abstractions
Lecture 22 Binary Search Trees Chapter 10 of textbook
Queues Chapter 4.
Binary Search Trees < > = Binary Search Trees
COMP9024: Data Structures and Algorithms
Part-D1 Priority Queues
Bohyung Han CSE, POSTECH
Heaps 9/13/2018 3:17 PM Heaps Heaps.
CS200: Algorithms Analysis
Data Structures and Database Applications Abstract Data Types
O(lg n) Search Tree Tree T is a search tree made up of n elements: x0 x1 x2 x3 … xn-1 No function (except transverse) takes more than O(lg n) in the.
Priority Queues © 2014 Goodrich, Tamassia, Goldwasser Priority Queues
Dictionaries < > = Dictionaries Dictionaries
Priority Queues and Heaps
Part-D1 Priority Queues
What is a heap? Always keep the thing we are most interested in close to the top (and fast to access). Like a binary search tree, but less structured.
Hash Tables 11/22/2018 3:15 AM Hash Tables  1 2  3  4
Binary Search Trees < > = Binary Search Trees
Heaps 11/27/ :05 PM Heaps Heaps.
Locators 3 a 1 g 4 e 12/1/2018 4:40 AM Locators Locators
Heaps and Priority Queues
© 2013 Goodrich, Tamassia, Goldwasser
Heaps 12/4/2018 5:27 AM Heaps /4/2018 5:27 AM Heaps.
Ch. 8 Priority Queues And Heaps
Priority Queues Sell 100 IBM $ $120 Buy 500 $ $118
Hassan Khosravi / Geoffrey Tien
Dictionaries < > = /9/2018 3:06 AM Dictionaries
Data Structures: Binary Search Trees
Priority Queues Sell 100 IBM $ $120 Buy 500 $ $118
Heaps II Implementation HeapSort Bottom-Up Heap Construction Locators.
Adaptable Priority Queues
CH 9 : Maps And Dictionary
Heaps © 2014 Goodrich, Tamassia, Goldwasser Heaps Heaps
Data Structures Lecture 29 Sohail Aslam.
CSE 12 – Basic Data Structures
CS210- Lecture 15 July 7, 2005 Agenda Median Heaps Adaptable PQ
Chapter 12 Heap ADT © 2011 Pearson Addison-Wesley. All rights reserved.
Instructor: Dr. Michael Geiger Spring 2019 Lecture 34: Exam 3 Preview
Dictionaries < > = Dictionaries Dictionaries
CS210- Lecture 14 July 5, 2005 Agenda Inserting into Heap
Heaps 9/29/2019 5:43 PM Heaps Heaps.
CMPT 225 Lecture 16 – Heap Sort.
Presentation transcript:

Locators 3 a 1 g 4 e 12/29/2018 7:56 AM Locators Locators

Outline and Reading Locators (§7.4, §9.6) Locator-based methods (§7.4.1) Implementation Positions vs. Locators 12/29/2018 7:56 AM Locators

Locators Application example: A locators identifies and tracks a (key, element) item within a data structure A locator sticks with a specific item, even if that element changes its position in the data structure Intuitive notion: claim check reservation number Methods of the locator ADT: key(): returns the key of the item associated with the locator element(): returns the element of the item associated with the locator Application example: Orders to purchase and sell a given stock are stored in two priority queues (sell orders and buy orders) the key of an order is the price the element is the number of shares When an order is placed, a locator to it is returned Given a locator, an order can be canceled or modified 12/29/2018 7:56 AM Locators

Locator-based Methods Locator-based priority queue methods: insert(k, o): inserts the item (k, o) and returns a locator for it min(): returns the locator of an item with smallest key remove(l): remove the item with locator l replaceKey(l, k): replaces the key of the item with locator l replaceElement(l, o): replaces with o the element of the item with locator l locators(): returns an iterator over the locators of the items in the priority queue Locator-based dictionary methods: insert(k, o): inserts the item (k, o) and returns its locator find(k): if the dictionary contains an item with key k, returns its locator, else return a special null locator remove(l): removes the item with locator l and returns its element locators(), replaceKey(l, k), replaceElement(l, o) 12/29/2018 7:56 AM Locators

Possible Implementation The locator is an object storing key element position (or rank) of the item in the underlying structure In turn, the position (or array cell) stores the locator Example: binary search tree with locators 6 d 3 a 9 b 1 g 4 e 8 c 12/29/2018 7:56 AM Locators

Positions vs. Locators Position represents a “place” in a data structure related to other positions in the data structure (e.g., previous/next or parent/child) often implemented as a pointer to a node or the index of an array cell Position-based ADTs (e.g., sequence and tree) are fundamental data storage schemes Locator identifies and tracks a (key, element) item unrelated to other locators in the data structure often implemented as an object storing the item and its position in the underlying structure Key-based ADTs (e.g., priority queue and dictionary) can be augmented with locator-based methods 12/29/2018 7:56 AM Locators