Download presentation
Presentation is loading. Please wait.
Published byNora Riley Modified over 8 years ago
1
Design and Analysis of Algorithms Dynamic Set Model Haidong Xue Summer 2012, at GSU
2
Motivation Programs manipulate data e.g. – Sorting – Wildfire simulation – Computer games – Google search engine In many cases, data can be represented as a “dynamic set”
3
Elements of a dynamic set – E.g. : ;. Satellite data – Unused data by set implementation (see page 229 for more details) 23617 5
4
Operations on dynamic set
5
SEARCH(S, k) MINIMUM(S) MAXIMUM(S) SUCCESSOR(S, x) PREDECESSOR(S, x) INSERT(S, x) DELETE(S, x) Input (S is known) Result 2361 7 5 6 6 (nothing) 1 7 67 65 4 23617 54 2361 5 7
6
Difference among data structures MAXIMUM(S) DELETE(S, x ) Array Linked-List 2 3 6 1 5 Max-heap Max: 2 3 6 6 O(n) 1 5 2 3 6 O(1) 1 5 23 6 3 O(n) 15 2 36 O(1) 1 5 2 3 6 O(n) Build-Max-Heap
7
Example: influence in quicksort 2 8 7 1 3 5 64 2 8 7 1 3 5 64 O(1) O(n) Do it in linked-list: 2 8 7 1 3 5 64 tail The last step of a partition: swap the pivot with A[tail+1] Do it in an array:
8
Examples Dynamic set examples – Webpage search Key: key words Satellite data: web page Frequent operation: SERACH – Simulation engine Key: model id Satellite data: model information Frequent operation: SEARCH, INSERT, DELETE
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.