1 / 12

Advanced Data Structures

Advanced Data Structures. (Random topics Gerth finds interesting...). Gerth Stølting Brodal. Formalities. Versions of course : ” normal ”, 3 implementation projects , groups 2-3 people ” honours ”, 4 theoretical projects , individual

marcie
Download Presentation

Advanced Data Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced Data Structures (Random topics Gerth finds interesting...) GerthStølting Brodal

  2. Formalities • Versions of course: • ”normal”, 3 implementationprojects, groups 2-3 people • ”honours”, 4 theoreticalprojects, individual • Exam: Individualdiscussionaboutprojects (Jan.) • Literature: Research papers • Lectures: Highleveldiscription of ideas

  3. Problem Input: Unordered list (x1,x2,...xn) and y1<y2<∙∙∙<yk Output: For eachyidetermineifyi is in the list *Comparison model

  4. Selection [T.H. Cormen, C.E. Leiserson, R.L. Rivest, C. Stein, Introduction to Algorithms, 2001, Chapter 9.3] Original [M. Blum, R.W. Floyd, V. Pratt, R. Rivest and R. Tarjan, Time bounds for selection, J. Comp. Syst. Sci. 7 (1973) 448-461] Problem: Given an array A of n elements and an integerk, find the k’th smallest element in A A 3’rd smallest (k=3)

  5. RandomizedSelectionAlgorithm • [C. A. R. Hoare: Algorithm 65: find. Commun. ACM 4(7): 321-322 (1961)] AlgorithmQuickSelect(A,k) p = random element from A A< = { e | e A and e < p } A> = { e | e A and e > p } if |A<|= k-1 thenreturnp if |A<|> k-1 thenreturnQuickSelect(A<,k) returnQuickSelect(A>, k-|A<|-1) ThmQuickSelect runs in expectedO(n) time Proof □

  6. DeterministicSelectionAlgorithm AlgorithmSelect(A,k) • if |A|= 1 thenA[1] A A’ p =Select(A’,|A’|/2) A< = { e | e A and e < p } A> = { e | e A and e > p } if |A<|= k-1 thenreturnp if |A<|> k-1 thenreturnSelect(A<,k) returnSelect(A>, k-|A<|-1) [M. Blum, R.W. Floyd, V. Pratt, R. Rivest and R. Tarjan, Time bounds for selection, J. Comp. Syst. Sci. 7 (1973) 448-461] n/5 groups ... 2 4 1 3 7 8 6 4 2 109 11 3 2 12 5 5 5 n/5 medians, one for eachgroup 3 69 ...

  7. Deterministic Selection Algorithm ThmSelect runs in worst-caseO(n) time Proof = O(n) □ 1 2 3 n/10+1 n/5 <p A’ >p considereachgroup as a sorted column

  8. Application: Lazy Construction of SearchTrees [Y.-T. Ching, K. Mehlhorn, M.H.M. Smid: Dynamic Deferred Data Structuring. Inf. Process. Lett. (IPL) 35(1):37-40 (1990)] 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 Construction T= sorting = O(n∙logn) SearchingO(log n) Construction + ksearchesO((n+k)∙logn)

  9. Application: Lazy Construction of SearchTrees Find rootusingselection/median and recurse 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 Construction O(n∙logn)

  10. Application: Lazy Construction of SearchTrees % 8 % 4 12 2 6 10 14 1 3 5 7 9 11 13 15 Search(7) Lazyconstruct nodes on 1 searchpath: 1+2+4+∙∙∙+n/2+n=O(n)

  11. Application: Lazy Construction of SearchTrees ThmLazyconstruction + ksearchesworst-case O(n∙logk) time Proof □ log klevelscompletelybuild O(n) time per level kleafpaths O(n/k) time per leaf

  12. ThmLazyconstruction + ksearchesrequiresworst-caseΩ(n∙logk) time Proof • Consider the elements of the input array in sortedorder, and considerkunsuccessfulsearchkeysy1<∙∙∙<yk. • The algorithm must determine the color (intevalbetweentwosearchkeys) of each element in the input array, otherwise an element could have beenequal to a searchkey. • Thereare (k+1)ncolorings. • A dicisiontree must determine the coloring. • Decision treedepth is ≥ log2(k+1)n = n∙log2 (k+1) □ y1 y2 yk unsuccesfullsearches

More Related