1 / 52

Shay Mozes (Brown University) Krzysztof Onak (MIT) Oren Weimann (MIT)

Binary Search on a Tree. Shay Mozes (Brown University) Krzysztof Onak (MIT) Oren Weimann (MIT). Locating differences – Binary Search on a Tree. ?. ?. =. 4. Locating differences – Binary Search on a Tree. ?. ?. =. 5. (a,c)?. c. a. (a,b)?. (c,e)?. e. c. a. b. b. (a,d)?.

luther
Télécharger la présentation

Shay Mozes (Brown University) Krzysztof Onak (MIT) Oren Weimann (MIT)

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. Binary Searchon a Tree Shay Mozes (Brown University) Krzysztof Onak (MIT) Oren Weimann (MIT)

  2. Locating differences – Binary Search on a Tree ? ? = 4

  3. Locating differences – Binary Search on a Tree ? ? = 5

  4. (a,c)? c a (a,b)? (c,e)? e c a b b (a,d)? (c,f)? (e,g)? a e g d c f a c d f e g Search Startegy • search strategy = decision tree • Optimal strategy = shallowest decision tree a b d c e f g

  5. Related Work Tree edge ranking • BFN [SODA 1997]:O(n4log3n) • LN [ENDM 2001]:2-approx. in O(nlogn) • OP [FOCS 2006]:O(n3) • This paper: O(n) Searching in trees and posets • IRV [Disc. Appl. Math. 1991]: 2-approx. in O(nlogn) • TGS [Algorithmica 1995]:O(n3logn) • LY [SODA 1998]:O(n)

  6. Strategy Function strategy function bounded by k decision tree of height k (a,c)? c a (a,b)? (c,e)? 1 e c a 2 b 3 b (a,d)? (c,f)? (e,g)? a e g d c f 1 2 a c d f e g 1 • f : E → {1,2,3,…} • If f(e1 ) = f(e2 ), then on the path from e1 to e2 there is e3 with f(e3 ) > f(e1 ) = f(e2 ) a b d c e f g

  7. (a,c)? c a (a,b)? (c,e)? 1 e c a 2 b a 3 b (a,d)? (c,f)? (e,g)? a e g d c f b d 1 2 c a c d f e g 1 e f g Solution Approach • Given tree • Find strategy function with the least maximum • Convert into a decision tree

  8. 3,1 3,2,1 Visibility • e is visible from vertex v if on path from v to e there is no value greater than e • Lexicographic order on visibility sequencese.g.: (3,2,1) > (3,1) a 1 3 d c 1 2 e f 1 g

  9. 3 2 c d 1 2 1 e f 1 f g Bottom-Up Approach • Given strategy functions at children of v • Given visibility sequences at children of v • Extend to minimal visibility sequence at v • Theorem [OP, de la Torre et al.]:Minimal extensions accumulate to an optimal solution v

  10. Valid Extension • An extension assigns all f(ei)’s v f(e1)? f(e2)? f(ek)? s1 s2 sk . . .

  11. Valid Extension • An extension assigns all f(ei)’s • f(ei)= f(ej) v 3 3 f(ek)? s1 s2 sk . . .

  12. Valid Extension • An extension assigns all f(ei)’s • f(ei)= f(ej) • f(ei) is not in si v 4 f(e2)? f(ek)? s1 s2 sk . . .

  13. Valid Extension • An extension assigns all f(ei)’s • f(ei)= f(ej) • f(ei) is not in si • f(ei) is in sjf(ej) > f(ei) v 3 4 f(e2)? s1 s2 sk . . .

  14. Valid Extension • An extension assigns all f(ei)’s • f(ei)= f(ej) • f(ei) is not in si • f(ei) is in sjf(ej) > f(ei) • u is in siand sjmax{f(ei), f(ei)} > u v 2 3 f(ek)? s1 s2 sk . . .

  15. Algorithm Outline v f(e1)? f(e2)? f(ek)? s1 s2 sk . . . free values

  16. Algorithm Outline • set u = max{si} v f(e1)? f(e2)? f(ek)? s1 s2 sk . . . u free values

  17. Algorithm Outline • set u = max{si} • while not all edges assigned v f(e1)? f(e2)? f(ek)? s1 s2 sk . . . u free values

  18. Algorithm Outline • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u v f(e1)? f(e2)? f(ek)? s1 s2 sk . . . u free values

  19. Algorithm Outline • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u v f(e1)? f(e2)? f(ek)? s1 s2 sk . . . u free values

  20. Algorithm Outline v f(e1)? f(e2)? f(ek)? s1 s2 sk . . . u free values • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise:

  21. Algorithm Outline • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u v f(e1)? f(e2)? f(ek)? s1 s2 sk . . . w u w free values

  22. Algorithm Outline • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj= anymaximal sequence w.r.tw v f(e1)? f(e2)? f(ek)? s1 s2 sk . . . w u w free values Sj

  23. Algorithm Outline • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj= anymaximal sequence w.r.tw • mark w as not free v f(e1)? f(e2)? f(ek)? s1 s2 sk . . . w u w free values Sj

  24. Algorithm Outline • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj= anymaximal sequence w.r.tw • mark w as not free • set currentf(ej) = w v 2 f(e2)? f(ek)? s1 s2 sk . . . w u w free values Sj

  25. Algorithm Outline • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj= anymaximal sequence w.r.tw • mark w as not free • set current f(ej) = w • mark allSj values between u and w as free v 2 f(e2)? f(ek)? s1 s2 sk . . . w u w free values Sj

  26. Algorithm Outline • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj= anymaximal sequence w.r.tw • mark w as not free • set current f(ej) = w • mark allSj values between u and w as free • remove all values < w fromSj v 2 f(e2)? f(ek)? s1 s2 sk . . . w u w free values Sj

  27. Algorithm Outline • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj= anymaximal sequence w.r.tw • mark w as not free • set current f(ej) = w • mark allSj values between u and w as free • remove all values < w fromSj v 2 f(e2)? f(ek)? s1 s2 sk . . . u free values

  28. Algorithm Outline • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj= anymaximal sequence w.r.tw • mark w as not free • set current f(ej) = w • mark allSj values between u and w as free • remove all values < w fromSj v 2 f(e2)? f(ek)? s1 s2 sk . . . u w free values Sj

  29. Algorithm Outline v 2 f(e2)? f(ek)? s1 s2 sk . . . u w free values • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj= anymaximal sequence w.r.tw • mark w as not free • set current f(ej) = w • mark allSj values between u and w as free • remove all values < w fromSj Sj

  30. Algorithm Outline v 2 3 f(ek)? s1 s2 sk . . . u w free values • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj= anymaximal sequence w.r.tw • mark w as not free • set current f(ej) = w • mark allSj values between u and w as free • remove all values < w fromSj Sj

  31. Algorithm Outline v 2 3 f(ek)? s1 s2 sk . . . u w free values • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj= anymaximal sequence w.r.tw • mark w as not free • set current f(ej) = w • mark allSj values between u and w as free • remove all values < w fromSj Sj

  32. Algorithm Outline v 2 3 f(ek)? s1 s2 sk . . . u free values • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj= anymaximal sequence w.r.tw • mark w as not free • set current f(ej) = w • mark allSj values between u and w as free • remove all values < w fromSj

  33. Algorithm Outline and u= 0 v 2 3 f(ek)? s1 s2 sk . . . u free values • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj= anymaximal sequence w.r.tw • mark w as not free • set current f(ej) = w • mark allSj values between u and w as free • remove all values < w fromSj

  34. Algorithm Outline and u= 0 v 2 3 f(ek)? w s1 s2 sk . . . w u free values • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj= anymaximal sequence w.r.tw • mark w as not free • set current f(ej) = w • mark allSj values between u and w as free • remove all values < w fromSj Sj

  35. Algorithm Outline and u= 0 v 2 3 f(ek)? w s1 s2 sk . . . w u free values • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj= anymaximal sequence w.r.tw • mark w as not free • set current f(ej) = w • mark allSj values between u and w as free • remove all values < w fromSj Sj

  36. Algorithm Outline and u= 0 v 5 3 f(ek)? w s1 s2 sk . . . w u free values • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj = anymaximal sequence w.r.t w • mark w as not free • set current f(ej) = w (free previous value) • mark all Sj values between u and w as free • remove all values < w fromSj Sj

  37. Algorithm Outline and u= 0 v 5 3 f(ek)? w s1 s2 sk . . . w u free values • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj = anymaximal sequence w.r.t w • mark w as not free • set current f(ej) = w (free previous value) • mark all Sj values between u and w as free • remove all values < w fromSj Sj

  38. Algorithm Outline and u= 0 v 5 3 f(ek)? s1 s2 sk . . . u free values • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj = anymaximal sequence w.r.t w • mark w as not free • set current f(ej) = w (free previous value) • mark all Sj values between u and w as free • remove all values < w fromSj

  39. Algorithm Outline and u= 0 v 5 3 f(ek)? s1 s2 sk . . . w w u free values • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj = anymaximal sequence w.r.t w • mark w as not free • set current f(ej) = w (free previous value) • mark all Sj values between u and w as free • remove all values < w fromSj Sj

  40. Algorithm Outline That’s it! and u= 0 v 5 3 2 s1 s2 sk . . . w w u free values • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj = anymaximal sequence w.r.t w • mark w as not free • set current f(ej) = w (free previous value) • mark all Sj values between u and w as free • remove all values < w fromSj Sj

  41. Algorithm Outline That’s it! • set u = max{si} • while not all edges assigned • if u appears once mark u as not free, move to next largest u • otherwise: • w= smallest free value > u • Sj = anymaximal sequence w.r.t w • mark w as not free • set current f(ej) = w (free previous value) • mark all Sj values between u and w as free • remove all values < w fromSj and u= 0 v s1 s1

  42. Running Time v s1 s2 sk . . .

  43. Running Time v s1 s2 sk . . . Easy in O(|S1| + |S2| +…+ |Sk|) per vertexO(n2) total

  44. Running Time v s1 s2 sk . . . Easy in O(|S1| + |S2| +…+ |Sk|) per vertexO(n2) total But, |S1| + |S2| +…+ |Sk| is not a lower bound!

  45. Running Time • in many cases, the largest values of the largest visibility sequence are unchanged at v itself v s1 s2 sk . . . Easy in O(|S1| + |S2| +…+ |Sk|) per vertexO(n2) total But, |S1| + |S2| +…+ |Sk| is not a lower bound!

  46. Linear Running Time • q(v) = |S2| +…+ |Sk| • k(v) = #v’s children • t(v) = largest value that appears in Sv but not in S1 • Theorem: an extension can be computed in time O( k(v)+q(v)+t(v) ) • Theorem: k(v)+q(v)+t(v) = O(n) • Differs from [LY98]: • different data structures • No bit tricks • O(n) decision tree construction v Σ v s1 s2 sk . . .

  47. From Strategy Function to Decision Tree in O(n) Time

  48. From Strategy Function to Decision Tree in O(n) Time (a,c)? a 1 2 c a 3 b d (a,b)? (c,e)? c 2 1 c e b a e f b 1 (a,d)? (c,f)? (e,g)? a g c d e f g a c d f e g

More Related