Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Median-of-k Quicksort is optimal for many equal keys

77 views

Published on

I gave this talk at ANALCO 2018;
see my website http://www.wild-inter.net/publications/wild-2018
for details and a preprint of the paper.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Median-of-k Quicksort is optimal for many equal keys

  1. 1. Median-of-k Quicksort Is Optimal For Many Equal Keys Sebastian Wild wild@uwaterloo.ca originates from joint work with Martin Aumüller, Martin Dietzfelbinger, Conrado Martínez, and Markus Nebel ANALCO 2018 15th Meeting on Analytic Algorithmics and Combinatorics Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 0 / 15
  2. 2. Outline 0 Intro0 Intro 1 Quicksort and Search Trees 1 Quicksort and Search Trees 2 Saturated Fringe-Balanced Trees 2 Saturated Fringe-Balanced Trees 3 Result3 Result Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 0 / 15
  3. 3. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  4. 4. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  5. 5. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  6. 6. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  7. 7. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  8. 8. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  9. 9. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  10. 10. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  11. 11. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  12. 12. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  13. 13. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  14. 14. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  15. 15. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  16. 16. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem pivot sampling but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  17. 17. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem pivot sampling Insertionsort cutoff but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  18. 18. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem pivot sampling Insertionsort cutoff multiway partitioning but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  19. 19. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem pivot sampling Insertionsort cutoff multiway partitioning Quickselect but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  20. 20. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem pivot sampling Insertionsort cutoff multiway partitioning Quickselect constant space but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  21. 21. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem pivot sampling Insertionsort cutoff multiway partitioning Quickselect constant space key comparisons but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  22. 22. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem pivot sampling Insertionsort cutoff multiway partitioning Quickselect constant space key comparisons symbol comparisons but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  23. 23. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem pivot sampling Insertionsort cutoff multiway partitioning Quickselect constant space key comparisons symbol comparisons swaps but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  24. 24. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem pivot sampling Insertionsort cutoff multiway partitioning Quickselect constant space key comparisons symbol comparisons swaps scanned elements but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  25. 25. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem pivot sampling Insertionsort cutoff multiway partitioning Quickselect constant space key comparisons symbol comparisons swaps scanned elements branch misses but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  26. 26. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem pivot sampling Insertionsort cutoff multiway partitioning Quickselect constant space key comparisons symbol comparisons swaps scanned elements branch misses but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  27. 27. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem pivot sampling Insertionsort cutoff multiway partitioning Quickselect constant space key comparisons symbol comparisons swaps scanned elements branch misses but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  28. 28. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem pivot sampling Insertionsort cutoff multiway partitioning Quickselect constant space key comparisons symbol comparisons swaps scanned elements branch misses but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  29. 29. Don’t we know everything about Quicksort by now? Extensive literature and results on Quicksort Type of result Analysis Techniques Algorithm variants Cost Measures expected costs variance tail inequalities limit distributions (semi-)local limit laws telescoping recurrences singularity analysis Euler differential eq. Martingales contraction method branching processes continuous master theorem pivot sampling Insertionsort cutoff multiway partitioning Quickselect constant space key comparisons symbol comparisons swaps scanned elements branch misses but: most results consider random permutations as input! partly justified: we can (shou not done in libraries ... ld!) randomize Quicksort, every input appears randomly ordered Catch: Elements with equal keys won’t go away! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 1 / 15
  30. 30. Setup Assumptions: 1 Input: (A) Multiset Model: Random permutation U1, . . . , Un of fixed multiset x1, . . . , xu number of occurrences of values 1, . . . , u (B) Discrete i.i.d. Model: U1, . . . , Un i.i.d. with Pr[U1 = v] = qv q = (q1, . . . , qu) a fixed universe distribution 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems of same type, (restricted to a sub-universe) 3 Cost: # ternary comparisons Median-of-(2t+1) Quicksort: median-of-(2t + 1) Example: t = 3 P t t(extension to asymmetric sampling possible) not today Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 2 / 15
  31. 31. Setup Assumptions: 1 Input: (A) Multiset Model: Random permutation U1, . . . , Un of fixed multiset x1, . . . , xu number of occurrences of values 1, . . . , u (B) Discrete i.i.d. Model: U1, . . . , Un i.i.d. with Pr[U1 = v] = qv q = (q1, . . . , qu) a fixed universe distribution 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems of same type, (restricted to a sub-universe) 3 Cost: # ternary comparisons Median-of-(2t+1) Quicksort: median-of-(2t + 1) Example: t = 3 P t t(extension to asymmetric sampling possible) not today Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 2 / 15
  32. 32. Setup Assumptions: 1 Input: (A) Multiset Model: Random permutation U1, . . . , Un of fixed multiset x1, . . . , xu profile x of input number of occurrences of values 1, . . . , u (B) Discrete i.i.d. Model: U1, . . . , Un i.i.d. with Pr[U1 = v] = qv q = (q1, . . . , qu) a fixed universe distribution 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems of same type, (restricted to a sub-universe) 3 Cost: # ternary comparisons Median-of-(2t+1) Quicksort: median-of-(2t + 1) Example: t = 3 P t t(extension to asymmetric sampling possible) not today Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 2 / 15
  33. 33. Setup Assumptions: 1 Input: (A) Multiset Model: Random permutation U1, . . . , Un of fixed multiset x1, . . . , xu profile x of input number of occurrences of values 1, . . . , u (B) Discrete i.i.d. Model: U1, . . . , Un i.i.d. with Pr[U1 = v] = qv q = (q1, . . . , qu) a fixed universe distribution 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems of same type, (restricted to a sub-universe) 3 Cost: # ternary comparisons Median-of-(2t+1) Quicksort: median-of-(2t + 1) Example: t = 3 P t t(extension to asymmetric sampling possible) not today Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 2 / 15
  34. 34. Setup Assumptions: 1 Input: (A) Multiset Model: Random permutation U1, . . . , Un of fixed multiset x1, . . . , xu profile x of input number of occurrences of values 1, . . . , u (B) Discrete i.i.d. Model: U1, . . . , Un i.i.d. with Pr[U1 = v] = qv random profile X D = Mult(n, q) q = (q1, . . . , qu) a fixed universe distribution 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems of same type, (restricted to a sub-universe) 3 Cost: # ternary comparisons Median-of-(2t+1) Quicksort: median-of-(2t + 1) Example: t = 3 P t t(extension to asymmetric sampling possible) not today Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 2 / 15
  35. 35. Setup Assumptions: 1 Input: (A) Multiset Model: Random permutation U1, . . . , Un of fixed multiset x1, . . . , xu profile x of input number of occurrences of values 1, . . . , u (B) Discrete i.i.d. Model: U1, . . . , Un i.i.d. with Pr[U1 = v] = qv random profile X D = Mult(n, q) q = (q1, . . . , qu) a fixed universe distribution 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems of same type, (restricted to a sub-universe) 3 Cost: # ternary comparisons Median-of-(2t+1) Quicksort: median-of-(2t + 1) Example: t = 3 P t t(extension to asymmetric sampling possible) not today Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 2 / 15
  36. 36. Setup Assumptions: 1 Input: (A) Multiset Model: Random permutation U1, . . . , Un of fixed multiset x1, . . . , xu profile x of input number of occurrences of values 1, . . . , u (B) Discrete i.i.d. Model: U1, . . . , Un i.i.d. with Pr[U1 = v] = qv random profile X D = Mult(n, q) q = (q1, . . . , qu) a fixed universe distribution 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems of same type, (restricted to a sub-universe) 3 Cost: # ternary comparisons Median-of-(2t+1) Quicksort: median-of-(2t + 1) Example: t = 3 P t t(extension to asymmetric sampling possible) not today Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 2 / 15
  37. 37. Setup Assumptions: 1 Input: (A) Multiset Model: Random permutation U1, . . . , Un of fixed multiset x1, . . . , xu profile x of input number of occurrences of values 1, . . . , u (B) Discrete i.i.d. Model: U1, . . . , Un i.i.d. with Pr[U1 = v] = qv random profile X D = Mult(n, q) q = (q1, . . . , qu) a fixed universe distribution 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems of same type, (restricted to a sub-universe) 3 Cost: # ternary comparisons Median-of-(2t+1) Quicksort: median-of-(2t + 1) Example: t = 3 P t t(extension to asymmetric sampling possible) not today Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 2 / 15
  38. 38. Setup Assumptions: 1 Input: (A) Multiset Model: Random permutation U1, . . . , Un of fixed multiset x1, . . . , xu profile x of input number of occurrences of values 1, . . . , u (B) Discrete i.i.d. Model: U1, . . . , Un i.i.d. with Pr[U1 = v] = qv random profile X D = Mult(n, q) q = (q1, . . . , qu) a fixed universe distribution 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems of same type, (restricted to a sub-universe) 3 Cost: # ternary comparisons Median-of-(2t+1) Quicksort: median-of-(2t + 1) Example: t = 3 P t t(extension to asymmetric sampling possible) not today Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 2 / 15
  39. 39. Setup Assumptions: 1 Input: (A) Multiset Model: Random permutation U1, . . . , Un of fixed multiset x1, . . . , xu profile x of input number of occurrences of values 1, . . . , u (B) Discrete i.i.d. Model: U1, . . . , Un i.i.d. with Pr[U1 = v] = qv random profile X D = Mult(n, q) q = (q1, . . . , qu) a fixed universe distribution 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems of same type, (restricted to a sub-universe) 3 Cost: # ternary comparisons Median-of-(2t+1) Quicksort: median-of-(2t + 1) Example: t = 3 P t t(extension to asymmetric sampling possible) not today Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 2 / 15
  40. 40. Setup Assumptions: 1 Input: (A) Multiset Model: Random permutation U1, . . . , Un of fixed multiset x1, . . . , xu profile x of input number of occurrences of values 1, . . . , u (B) Discrete i.i.d. Model: U1, . . . , Un i.i.d. with Pr[U1 = v] = qv random profile X D = Mult(n, q) q = (q1, . . . , qu) a fixed universe distribution 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems of same type, (restricted to a sub-universe) 3 Cost: # ternary comparisons Median-of-(2t+1) Quicksort: median-of-(2t + 1) Example: t = 3 P t t(extension to asymmetric sampling possible) not today Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 2 / 15
  41. 41. Setup Assumptions: 1 Input: (A) Multiset Model: Random permutation U1, . . . , Un of fixed multiset x1, . . . , xu profile x of input number of occurrences of values 1, . . . , u (B) Discrete i.i.d. Model: U1, . . . , Un i.i.d. with Pr[U1 = v] = qv random profile X D = Mult(n, q) q = (q1, . . . , qu) a fixed universe distribution 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems of same type, (restricted to a sub-universe) 3 Cost: # ternary comparisons Median-of-(2t+1) Quicksort: median-of-(2t + 1) Example: t = 3 P t t(extension to asymmetric sampling possible) not today Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 2 / 15
  42. 42. Previous work on equal keys Rather little is known! Sedgewick 1977: Quicksort on Equal Keys Sedgewick & Bentley 2002: Quicksort is Optimal (Talk at Knuthfest) A bit more on BSTs: Burge 1976: An Analysis of BSTs Formed from Sequences of Nondistinct Keys Kemp 1996: BSTs constructed from nondistinct keys with/without specified probabilities Archibald & Clément 2006: Average depth in a BST with repeated keys This is basically all literature on analysis of Quicksort with equal keys! Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 3 / 15
  43. 43. Previous work on equal keys Rather little is known! Sedgewick 1977: Quicksort on Equal Keys Sedgewick & Bentley 2002: Quicksort is Optimal (Talk at Knuthfest) A bit more on BSTs: Burge 1976: An Analysis of BSTs Formed from Sequences of Nondistinct Keys Kemp 1996: BSTs constructed from nondistinct keys with/without specified probabilities Archibald & Clément 2006: Average depth in a BST with repeated keys This is basically all literature on analysis of Quicksort with equal keys! SIAM J. COMPUT. Vol. 6, No. 2, June 1977 QUICKSORT WITH EQUAL KEYS* ROBERT SEDGEWICK? Abstract. This paper considers the problem of implementing and analyzing a Quicksort program when equal keys are likely to be present in the file to be sorted. Upper and lower bounds are derived on the average number of comparisons needed by any Quicksort programwhen equal keys are present. It is shown that, of the three strategies which have been suggested for dealing with equal keys, the method of always stopping the scanning pointers on keys equal to the partitioning element performs best. Key words, analysis of algorithms, equal keys, Quicksort, sorting Introduction. The Quicksort algorithm, which was introduced by C. A. R. Hoare in 1960 [6], [7], has gained wide acceptance as the most efficientSebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 3 / 15
  44. 44. Previous work on equal keys Rather little is known! Sedgewick 1977: Quicksort on Equal Keys Sedgewick & Bentley 2002: Quicksort is Optimal (Talk at Knuthfest) A bit more on BSTs: Burge 1976: An Analysis of BSTs Formed from Sequences of Nondistinct Keys Kemp 1996: BSTs constructed from nondistinct keys with/without specified probabilities Archibald & Clément 2006: Average depth in a BST with repeated keys This is basically all literature on analysis of Quicksort with equal keys! SIAM J. COMPUT. Vol. 6, No. 2, June 1977 QUICKSORT WITH EQUAL KEYS* ROBERT SEDGEWICK? Abstract. This paper considers the problem of implementing and analyzing a Quicksort program when equal keys are likely to be present in the file to be sorted. Upper and lower bounds are derived on the average number of comparisons needed by any Quicksort programwhen equal keys are present. It is shown that, of the three strategies which have been suggested for dealing with equal keys, the method of always stopping the scanning pointers on keys equal to the partitioning element performs best. Key words, analysis of algorithms, equal keys, Quicksort, sorting Introduction. The Quicksort algorithm, which was introduced by C. A. R. Hoare in 1960 [6], [7], has gained wide acceptance as the most efficient Now is the time For all good men To come to the aid Of their party QUICKSORT IS OPTIMAL Robert Sedgewick Jon Bentley Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 3 / 15
  45. 45. Previous work on equal keys Rather little is known! Sedgewick 1977: Quicksort on Equal Keys Sedgewick & Bentley 2002: Quicksort is Optimal (Talk at Knuthfest) A bit more on BSTs: Burge 1976: An Analysis of BSTs Formed from Sequences of Nondistinct Keys Kemp 1996: BSTs constructed from nondistinct keys with/without specified probabilities Archibald & Clément 2006: Average depth in a BST with repeated keys This is basically all literature on analysis of Quicksort with equal keys! SIAM J. COMPUT. Vol. 6, No. 2, June 1977 QUICKSORT WITH EQUAL KEYS* ROBERT SEDGEWICK? Abstract. This paper considers the problem of implementing and analyzing a Quicksort program when equal keys are likely to be present in the file to be sorted. Upper and lower bounds are derived on the average number of comparisons needed by any Quicksort programwhen equal keys are present. It is shown that, of the three strategies which have been suggested for dealing with equal keys, the method of always stopping the scanning pointers on keys equal to the partitioning element performs best. Key words, analysis of algorithms, equal keys, Quicksort, sorting Introduction. The Quicksort algorithm, which was introduced by C. A. R. Hoare in 1960 [6], [7], has gained wide acceptance as the most efficient Now is the time For all good men To come to the aid Of their party QUICKSORT IS OPTIMAL Robert Sedgewick Jon Bentley An Analysis of Binary Search Trees Formed from Sequences of Nondistinct Keys WILLIAM H. BURGE IBM Thomas J. Watson Research Center, Yorktown Heights, New York ABSTRACT. The expected depth of each key in the set of binary search trees formed from all sequences composed from a multmet {pl • 1, p2 ' 2, p3 • 3, ..., p~ • n} is obtained, and hence the expected weight of such trees. The expected number of left-to-right local minima and the expected number of cycles in sequences composed from a multiset are then deduced from these results. KEY WORDS AND PHRASES : binary search trees, multiset CR CATEGORIES: 5.3 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 3 / 15
  46. 46. Previous work on equal keys Rather little is known! Sedgewick 1977: Quicksort on Equal Keys Sedgewick & Bentley 2002: Quicksort is Optimal (Talk at Knuthfest) A bit more on BSTs: Burge 1976: An Analysis of BSTs Formed from Sequences of Nondistinct Keys Kemp 1996: BSTs constructed from nondistinct keys with/without specified probabilities Archibald & Clément 2006: Average depth in a BST with repeated keys This is basically all literature on analysis of Quicksort with equal keys! SIAM J. COMPUT. Vol. 6, No. 2, June 1977 QUICKSORT WITH EQUAL KEYS* ROBERT SEDGEWICK? Abstract. This paper considers the problem of implementing and analyzing a Quicksort program when equal keys are likely to be present in the file to be sorted. Upper and lower bounds are derived on the average number of comparisons needed by any Quicksort programwhen equal keys are present. It is shown that, of the three strategies which have been suggested for dealing with equal keys, the method of always stopping the scanning pointers on keys equal to the partitioning element performs best. Key words, analysis of algorithms, equal keys, Quicksort, sorting Introduction. The Quicksort algorithm, which was introduced by C. A. R. Hoare in 1960 [6], [7], has gained wide acceptance as the most efficient Now is the time For all good men To come to the aid Of their party QUICKSORT IS OPTIMAL Robert Sedgewick Jon Bentley An Analysis of Binary Search Trees Formed from Sequences of Nondistinct Keys WILLIAM H. BURGE IBM Thomas J. Watson Research Center, Yorktown Heights, New York ABSTRACT. The expected depth of each key in the set of binary search trees formed from all sequences composed from a multmet {pl • 1, p2 ' 2, p3 • 3, ..., p~ • n} is obtained, and hence the expected weight of such trees. The expected number of left-to-right local minima and the expected number of cycles in sequences composed from a multiset are then deduced from these results. KEY WORDS AND PHRASES : binary search trees, multiset CR CATEGORIES: 5.3 Theoretical Computer Science ELSEVIER Theoretical Computer Science 156 (1996) 39%70 Binary search trees constructed from nondistinct keys with/without specified probabilities Rainer Kemp Johann Wo@ng Goethe-Universitiit, Fachbereich Informarik, D-60054 Fran!+rt am Main, German) Received May 1994; revised November 1994Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 3 / 15
  47. 47. Previous work on equal keys Rather little is known! Sedgewick 1977: Quicksort on Equal Keys Sedgewick & Bentley 2002: Quicksort is Optimal (Talk at Knuthfest) A bit more on BSTs: Burge 1976: An Analysis of BSTs Formed from Sequences of Nondistinct Keys Kemp 1996: BSTs constructed from nondistinct keys with/without specified probabilities Archibald & Clément 2006: Average depth in a BST with repeated keys This is basically all literature on analysis of Quicksort with equal keys! SIAM J. COMPUT. Vol. 6, No. 2, June 1977 QUICKSORT WITH EQUAL KEYS* ROBERT SEDGEWICK? Abstract. This paper considers the problem of implementing and analyzing a Quicksort program when equal keys are likely to be present in the file to be sorted. Upper and lower bounds are derived on the average number of comparisons needed by any Quicksort programwhen equal keys are present. It is shown that, of the three strategies which have been suggested for dealing with equal keys, the method of always stopping the scanning pointers on keys equal to the partitioning element performs best. Key words, analysis of algorithms, equal keys, Quicksort, sorting Introduction. The Quicksort algorithm, which was introduced by C. A. R. Hoare in 1960 [6], [7], has gained wide acceptance as the most efficient Now is the time For all good men To come to the aid Of their party QUICKSORT IS OPTIMAL Robert Sedgewick Jon Bentley An Analysis of Binary Search Trees Formed from Sequences of Nondistinct Keys WILLIAM H. BURGE IBM Thomas J. Watson Research Center, Yorktown Heights, New York ABSTRACT. The expected depth of each key in the set of binary search trees formed from all sequences composed from a multmet {pl • 1, p2 ' 2, p3 • 3, ..., p~ • n} is obtained, and hence the expected weight of such trees. The expected number of left-to-right local minima and the expected number of cycles in sequences composed from a multiset are then deduced from these results. KEY WORDS AND PHRASES : binary search trees, multiset CR CATEGORIES: 5.3 Theoretical Computer Science ELSEVIER Theoretical Computer Science 156 (1996) 39%70 Binary search trees constructed from nondistinct keys with/without specified probabilities Rainer Kemp Johann Wo@ng Goethe-Universitiit, Fachbereich Informarik, D-60054 Fran!+rt am Main, German) Received May 1994; revised November 1994 Fourth Colloquium on Mathematics and Computer Science DMTCS proc. AG, 2006, 309–320 Average depth in a binary search tree with repeated keys Margaret Archibald1 and Julien Cl´ement2,3 1 School of Mathematics, University of the Witwatersrand, P. O. Wits, 2050 Johannesburg, South Africa, email: marchibald@maths.wits.ac.za. 2 CNRS UMR 8049, Institut Gaspard-Monge, Laboratoire d’informatique, Universit´e de Marne-la-Vall´ee, France 3 CNRS UMR 6072, GREYC Laboratoire d’informatique, Universit´e de Caen, France, email: Julien.Clement@info.unicaen.frSebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 3 / 15
  48. 48. Previous work on equal keys Rather little is known! Sedgewick 1977: Quicksort on Equal Keys Sedgewick & Bentley 2002: Quicksort is Optimal (Talk at Knuthfest) A bit more on BSTs: Burge 1976: An Analysis of BSTs Formed from Sequences of Nondistinct Keys Kemp 1996: BSTs constructed from nondistinct keys with/without specified probabilities Archibald & Clément 2006: Average depth in a BST with repeated keys This is basically all literature on analysis of Quicksort with equal keys! SIAM J. COMPUT. Vol. 6, No. 2, June 1977 QUICKSORT WITH EQUAL KEYS* ROBERT SEDGEWICK? Abstract. This paper considers the problem of implementing and analyzing a Quicksort program when equal keys are likely to be present in the file to be sorted. Upper and lower bounds are derived on the average number of comparisons needed by any Quicksort programwhen equal keys are present. It is shown that, of the three strategies which have been suggested for dealing with equal keys, the method of always stopping the scanning pointers on keys equal to the partitioning element performs best. Key words, analysis of algorithms, equal keys, Quicksort, sorting Introduction. The Quicksort algorithm, which was introduced by C. A. R. Hoare in 1960 [6], [7], has gained wide acceptance as the most efficient Now is the time For all good men To come to the aid Of their party QUICKSORT IS OPTIMAL Robert Sedgewick Jon Bentley An Analysis of Binary Search Trees Formed from Sequences of Nondistinct Keys WILLIAM H. BURGE IBM Thomas J. Watson Research Center, Yorktown Heights, New York ABSTRACT. The expected depth of each key in the set of binary search trees formed from all sequences composed from a multmet {pl • 1, p2 ' 2, p3 • 3, ..., p~ • n} is obtained, and hence the expected weight of such trees. The expected number of left-to-right local minima and the expected number of cycles in sequences composed from a multiset are then deduced from these results. KEY WORDS AND PHRASES : binary search trees, multiset CR CATEGORIES: 5.3 Theoretical Computer Science ELSEVIER Theoretical Computer Science 156 (1996) 39%70 Binary search trees constructed from nondistinct keys with/without specified probabilities Rainer Kemp Johann Wo@ng Goethe-Universitiit, Fachbereich Informarik, D-60054 Fran!+rt am Main, German) Received May 1994; revised November 1994 Fourth Colloquium on Mathematics and Computer Science DMTCS proc. AG, 2006, 309–320 Average depth in a binary search tree with repeated keys Margaret Archibald1 and Julien Cl´ement2,3 1 School of Mathematics, University of the Witwatersrand, P. O. Wits, 2050 Johannesburg, South Africa, email: marchibald@maths.wits.ac.za. 2 CNRS UMR 8049, Institut Gaspard-Monge, Laboratoire d’informatique, Universit´e de Marne-la-Vall´ee, France 3 CNRS UMR 6072, GREYC Laboratoire d’informatique, Universit´e de Caen, France, email: Julien.Clement@info.unicaen.frSebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 3 / 15
  49. 49. Previous work on equal keys Rather little is known! Sedgewick 1977: Quicksort on Equal Keys Sedgewick & Bentley 2002: Quicksort is Optimal (Talk at Knuthfest) A bit more on BSTs: Burge 1976: An Analysis of BSTs Formed from Sequences of Nondistinct Keys Kemp 1996: BSTs constructed from nondistinct keys with/without specified probabilities Archibald & Clément 2006: Average depth in a BST with repeated keys This is basically all literature on analysis of Quicksort with equal keys! SIAM J. COMPUT. Vol. 6, No. 2, June 1977 QUICKSORT WITH EQUAL KEYS* ROBERT SEDGEWICK? Abstract. This paper considers the problem of implementing and analyzing a Quicksort program when equal keys are likely to be present in the file to be sorted. Upper and lower bounds are derived on the average number of comparisons needed by any Quicksort programwhen equal keys are present. It is shown that, of the three strategies which have been suggested for dealing with equal keys, the method of always stopping the scanning pointers on keys equal to the partitioning element performs best. Key words, analysis of algorithms, equal keys, Quicksort, sorting Introduction. The Quicksort algorithm, which was introduced by C. A. R. Hoare in 1960 [6], [7], has gained wide acceptance as the most efficient Now is the time For all good men To come to the aid Of their party QUICKSORT IS OPTIMAL Robert Sedgewick Jon Bentley An Analysis of Binary Search Trees Formed from Sequences of Nondistinct Keys WILLIAM H. BURGE IBM Thomas J. Watson Research Center, Yorktown Heights, New York ABSTRACT. The expected depth of each key in the set of binary search trees formed from all sequences composed from a multmet {pl • 1, p2 ' 2, p3 • 3, ..., p~ • n} is obtained, and hence the expected weight of such trees. The expected number of left-to-right local minima and the expected number of cycles in sequences composed from a multiset are then deduced from these results. KEY WORDS AND PHRASES : binary search trees, multiset CR CATEGORIES: 5.3 Theoretical Computer Science ELSEVIER Theoretical Computer Science 156 (1996) 39%70 Binary search trees constructed from nondistinct keys with/without specified probabilities Rainer Kemp Johann Wo@ng Goethe-Universitiit, Fachbereich Informarik, D-60054 Fran!+rt am Main, German) Received May 1994; revised November 1994 Fourth Colloquium on Mathematics and Computer Science DMTCS proc. AG, 2006, 309–320 Average depth in a binary search tree with repeated keys Margaret Archibald1 and Julien Cl´ement2,3 1 School of Mathematics, University of the Witwatersrand, P. O. Wits, 2050 Johannesburg, South Africa, email: marchibald@maths.wits.ac.za. 2 CNRS UMR 8049, Institut Gaspard-Monge, Laboratoire d’informatique, Universit´e de Marne-la-Vall´ee, France 3 CNRS UMR 6072, GREYC Laboratoire d’informatique, Universit´e de Caen, France, email: Julien.Clement@info.unicaen.fr All these works only consider classic Quicksort: No sampling to choose pivots. (No multiway partitioning.) Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 3 / 15
  50. 50. Sedgewick’s analysis for classic Quicksort Classic Quicksort: Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 4 / 15
  51. 51. Sedgewick’s analysis for classic Quicksort Classic Quicksort: € C(1,n) = N − 1 + 1 N xj(C(1, j − 1) + C(j + 1,n)) 1≤j≤n ∑ Analysis of Quicksort with equal keys € NC(1,n) = N(N − 1) + xjC(1,j − 1) + xj 1≤j≤n ∑ C(j + 1,n) 1≤j≤n ∑ € (x1 + ...+ xn)D(1,n) = x1 2 − x1 + 2x1(x2 +... + xn) + xjD(1,j − 1) 2≤j≤n ∑ € (x1 + ...+ xn)D(1,n) − (x1 + ...+ xn−1)D(1,n− 1) = 2x1xn + xnD(1,n − 1) 1. Define € C(x1,...,xn) ≡ C(1,n) to be the mean # compares to sort the file 3. Subtract same equation for € x2,...,xn and let € D(1,n) ≡ C(1,n) − C(2,n) 2. Multiply both sides by € N = x1 +...+ xn 4. Subtract same equation for € x1,...,xn−1 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 4 / 15
  52. 52. Sedgewick’s analysis for classic Quicksort Classic Quicksort: € C(1,n) = N − 1 + 1 N xj(C(1, j − 1) + C(j + 1,n)) 1≤j≤n ∑ Analysis of Quicksort with equal keys € NC(1,n) = N(N − 1) + xjC(1,j − 1) + xj 1≤j≤n ∑ C(j + 1,n) 1≤j≤n ∑ € (x1 + ...+ xn)D(1,n) = x1 2 − x1 + 2x1(x2 +... + xn) + xjD(1,j − 1) 2≤j≤n ∑ € (x1 + ...+ xn)D(1,n) − (x1 + ...+ xn−1)D(1,n− 1) = 2x1xn + xnD(1,n − 1) 1. Define € C(x1,...,xn) ≡ C(1,n) to be the mean # compares to sort the file 3. Subtract same equation for € x2,...,xn and let € D(1,n) ≡ C(1,n) − C(2,n) 2. Multiply both sides by € N = x1 +...+ xn 4. Subtract same equation for € x1,...,xn−1 € D(1,n) = D(1,n − 1) + 2x1xn x1 +...+ xn Analysis of Quicksort with equal keys (cont.) € (x1 + ...+ xn)D(1,n) − (x1 + ...+ xn−1)D(1,n− 1) = 2x1xn + xnD(1,n − 1) 5. Simplify, divide both sides by € N = x1 +...+ xn 6. Telescope (twice) THEOREM. Quicksort (with 3-way partitioning, randomized) uses € N − n+ 2QN compares (where € Q = pkpj pk +...+ pj1≤k<j≤n ∑ , with € pi = xi N) to sort an € (x1,...,xn) −file, on the average . € C(1,n) = N − n + 2xkxj xk +... + xj1≤k<j≤n ∑ Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 4 / 15
  53. 53. Sedgewick’s analysis for classic Quicksort Classic Quicksort: Expected comparisons expressible exactly. € C(1,n) = N − 1 + 1 N xj(C(1, j − 1) + C(j + 1,n)) 1≤j≤n ∑ Analysis of Quicksort with equal keys € NC(1,n) = N(N − 1) + xjC(1,j − 1) + xj 1≤j≤n ∑ C(j + 1,n) 1≤j≤n ∑ € (x1 + ...+ xn)D(1,n) = x1 2 − x1 + 2x1(x2 +... + xn) + xjD(1,j − 1) 2≤j≤n ∑ € (x1 + ...+ xn)D(1,n) − (x1 + ...+ xn−1)D(1,n− 1) = 2x1xn + xnD(1,n − 1) 1. Define € C(x1,...,xn) ≡ C(1,n) to be the mean # compares to sort the file 3. Subtract same equation for € x2,...,xn and let € D(1,n) ≡ C(1,n) − C(2,n) 2. Multiply both sides by € N = x1 +...+ xn 4. Subtract same equation for € x1,...,xn−1 € D(1,n) = D(1,n − 1) + 2x1xn x1 +...+ xn Analysis of Quicksort with equal keys (cont.) € (x1 + ...+ xn)D(1,n) − (x1 + ...+ xn−1)D(1,n− 1) = 2x1xn + xnD(1,n − 1) 5. Simplify, divide both sides by € N = x1 +...+ xn 6. Telescope (twice) THEOREM. Quicksort (with 3-way partitioning, randomized) uses € N − n+ 2QN compares (where € Q = pkpj pk +...+ pj1≤k<j≤n ∑ , with € pi = xi N) to sort an € (x1,...,xn) −file, on the average . € C(1,n) = N − n + 2xkxj xk +... + xj1≤k<j≤n ∑ € D(1,n) = D(1,n − 1) + 2x1xn x1 +...+ xn Analysis of Quicksort with equal keys (cont.) € (x1 + ...+ xn)D(1,n) − (x1 + ...+ xn−1)D(1,n− 1) = 2x1xn + xnD(1,n − 1) 5. Simplify, divide both sides by € N = x1 +...+ xn 6. Telescope (twice) THEOREM. Quicksort (with 3-way partitioning, randomized) uses € N − n+ 2QN compares (where Q = pkpj pk +...+ pj1≤k<j≤n ∑ , with € pi = xi N) to sort an (x1,...,xn) −file, on the average . € C(1,n) = N − n + 2xkxj xk +... + xj1≤k<j≤n ∑ Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 4 / 15
  54. 54. The conjecture of Sedgewick and Bentley Quicksort is optimal The average number of compares per element C/N is always within a constant factor of the entropy H lower bound: € C > NH − N (information theory) upper bound: € C < 2ln2NH + N (Burge analysis, Melhorn bound) No comparison-based algorithm can do better. Conjecture: With sampling, € C / N → H as sample size increases. Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 5 / 15
  55. 55. The conjecture of Sedgewick and Bentley Quicksort is optimal The average number of compares per element C/N is always within a constant factor of the entropy H lower bound: € C > NH − N (information theory) upper bound: € C < 2ln2NH + N (Burge analysis, Melhorn bound) No comparison-based algorithm can do better. Conjecture: With sampling, € C / N → H as sample size increases. Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 5 / 15
  56. 56. The conjecture of Sedgewick and Bentley Quicksort is optimal The average number of compares per element C/N is always within a constant factor of the entropy H lower bound: € C > NH − N (information theory) upper bound: € C < 2ln2NH + N (Burge analysis, Melhorn bound) No comparison-based algorithm can do better. Conjecture: With sampling, € C / N → H as sample size increases. ∗ * subject to some restrictions Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 5 / 15
  57. 57. The conjecture of Sedgewick and Bentley Quicksort is optimal The average number of compares per element C/N is always within a constant factor of the entropy H lower bound: € C > NH − N (information theory) upper bound: € C < 2ln2NH + N (Burge analysis, Melhorn bound) No comparison-based algorithm can do better. Conjecture: With sampling, € C / N → H as sample size increases. ∗ * subject to some restrictions Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 5 / 15
  58. 58. Outline 0 Intro0 Intro 1 Quicksort and Search Trees 1 Quicksort and Search Trees 2 Saturated Fringe-Balanced Trees 2 Saturated Fringe-Balanced Trees 3 Result3 Result Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 5 / 15
  59. 59. Quicksort & search trees Classic Fact: Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  60. 60. Quicksort & search trees Classic Fact: Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  61. 61. Quicksort & search trees Classic Fact: Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  62. 62. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  63. 63. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) 4 2 1 3 3 5 4 4 3 5 2 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  64. 64. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) 4 2 1 3 3 5 4 4 3 5 2 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  65. 65. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 5 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  66. 66. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  67. 67. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  68. 68. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  69. 69. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  70. 70. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  71. 71. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  72. 72. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  73. 73. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  74. 74. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 4 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  75. 75. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 4 2 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  76. 76. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 4 2 1 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  77. 77. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 4 2 1 3 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  78. 78. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 4 2 1 3 3 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  79. 79. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 4 2 1 3 5 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  80. 80. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 4 2 1 3 5 4 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  81. 81. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 4 2 1 3 5 1 4 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  82. 82. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 4 2 1 3 5 1 3 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  83. 83. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 4 2 1 3 5 1 5 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  84. 84. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 4 2 1 3 5 1 2 Equivalence holds also with duplicates. Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  85. 85. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 4 2 1 3 5 1 Equivalence holds also with duplicates. Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  86. 86. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 4 2 1 3 5 1 Equivalence holds also with duplicates. This was only basic Quicksort ... how about pivot sampling? Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  87. 87. Quicksort & search trees Classic Fact: (without duplicates) Recursion Tree of Quicksort = Naturally grown BST from input Comparisons in Quicksort = Comparisons to built BST = Comparisons to search input in final BST How about inputs with duplicates? Quicksort (Fat-Pivot) Binary Search Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 3 2 5 54 44 1 3 3 32 2 5 5 1 3 33 4 2 1 3 3 5 4 4 3 5 2 4 2 1 3 5 1 Equivalence holds also with duplicates. This was only basic Quicksort ... how about pivot sampling? Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 6 / 15
  88. 88. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  89. 89. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  90. 90. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 4 2 1 3 3 5 4 4 3 5 2 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  91. 91. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 4 2 1 3 3 5 4 4 3 5 2 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  92. 92. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 4 2 1 3 3 5 4 4 3 5 2 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  93. 93. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  94. 94. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 Insertionsort Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  95. 95. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  96. 96. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  97. 97. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 44 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  98. 98. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 44 Insertionsort Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  99. 99. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  100. 100. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  101. 101. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 4 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  102. 102. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 4 2 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  103. 103. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 4 2 1 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  104. 104. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 4 2 1 3 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  105. 105. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 4 2 1 3 3 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  106. 106. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 2 1 3 3 4 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  107. 107. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 2 1 43 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  108. 108. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 3 2 1 4 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  109. 109. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 3 2 1 4 5 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  110. 110. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 3 2 1 4 5 4 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  111. 111. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 3 2 1 4 5 4 4 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  112. 112. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 3 4 5 4 42 1 3 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  113. 113. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 3 2 1 4 5 4 4 5 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  114. 114. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 3 2 1 4 4 4 5 5 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  115. 115. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 3 2 1 5 54 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  116. 116. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 3 2 1 4 5 5 Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  117. 117. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 3 4 5 5 2 1 2 Correspondence extends to Pivot Sampling (any scheme, not only median) (s-way Partitioning s-ary search trees) not today Analyze search trees instead of Quicksort. Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  118. 118. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 3 4 5 5 2 1 2 Correspondence extends to Pivot Sampling (any scheme, not only median) (s-way Partitioning s-ary search trees) not today Analyze search trees instead of Quicksort. Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  119. 119. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 3 4 5 5 2 1 2 Correspondence extends to Pivot Sampling (any scheme, not only median) (s-way Partitioning s-ary search trees) not today Analyze search trees instead of Quicksort. Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  120. 120. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 3 4 5 5 2 1 2 Correspondence extends to Pivot Sampling (any scheme, not only median) (s-way Partitioning s-ary search trees) not today Analyze search trees instead of Quicksort. Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  121. 121. Fringe-balanced trees k-Fringe-Balanced Search Trees: Leaves buffer k = 2t + 1 elements. If buffer is full, leaf is split new internal node with chosen pivot. Median-of-5 Quicksort (t = 2) 5-Fringe-Balanced Tree 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 5 54 442 1 2 5 5 4 2 1 3 3 5 4 4 3 5 2 3 4 5 5 2 1 2 Correspondence extends to Pivot Sampling (any scheme, not only median) (s-way Partitioning s-ary search trees) not today Analyze search trees instead of Quicksort. Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 7 / 15
  122. 122. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  123. 123. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  124. 124. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  125. 125. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  126. 126. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  127. 127. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  128. 128. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  129. 129. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  130. 130. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  131. 131. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  132. 132. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  133. 133. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  134. 134. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  135. 135. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  136. 136. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  137. 137. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  138. 138. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  139. 139. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Fringe-balanced: stationary after each value inserted k = 2t + 1 times (up to k duplicates in buffer) Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  140. 140. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) Observation: T becomes stationary after each value was inserted! Fringe-balanced: stationary after each value inserted k = 2t + 1 times (up to k duplicates in buffer) Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  141. 141. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) tree-growing part T Observation: T becomes stationary after each value was inserted! Fringe-balanced: stationary after each value inserted k = 2t + 1 times (up to k duplicates in buffer) Split input into tree-growing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  142. 142. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) tree-growing part T Observation: T becomes stationary after each value was inserted! Fringe-balanced: stationary after each value inserted k = 2t + 1 times (up to k duplicates in buffer) Split input into tree-grow hopefully a short prefix! ing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  143. 143. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) tree-growing part T searching part XS Observation: T becomes stationary after each value was inserted! Fringe-balanced: stationary after each value inserted k = 2t + 1 times (up to k duplicates in buffer) Split input into tree-grow hopefully a short prefix! ing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  144. 144. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) tree-growing part T searching part XS Observation: T becomes stationary after each value was inserted! Fringe-balanced: stationary after each value inserted k = 2t + 1 times (up to k duplicates in buffer) Split input into tree-grow hopefully a short prefix! ing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. Two parts of input always dependent! (profiles must sum to x) Two parts are independent (i.i.d.!)profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  145. 145. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) tree-growing part T searching part XS Observation: T becomes stationary after each value was inserted! Fringe-balanced: stationary after each value inserted k = 2t + 1 times (up to k duplicates in buffer) Split input into tree-grow hopefully a short prefix! ing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. Two parts of input always dependent! (profiles must sum to x) Two parts are independent (i.i.d.!)profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  146. 146. Tree-growing and searching Quicksort costs = costs to search input U = (U1, . . . , Un) in final tree T. T fixed search cost depends only on profile X = (X1, . . . , Xu) but: T also depends on U (Recall: T is built from U!) direct analysis no simpler than for Quicksort 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 (k = 1) tree-growing part T searching part XS Observation: T becomes stationary after each value was inserted! Fringe-balanced: stationary after each value inserted k = 2t + 1 times (up to k duplicates in buffer) Split input into tree-grow hopefully a short prefix! ing part and searching part: 1 We built T until it is stationary, ignoring costs. 2 Determine costs of searching remaining elements. Two parts of input always dependent! (profiles must sum to x) Two parts are independent (i.i.d.!)profile XS of search part independent of T Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 8 / 15
  147. 147. Bounding the tree-growing part Goal: ignore tree-growing for analysis. 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 Allow only first nT elements for tree growing. Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 9 / 15
  148. 148. Bounding the tree-growing part Goal: ignore tree-growing for analysis. 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 tree-growing part T searching part XSnT Allow only first nT elements for tree growing. Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 9 / 15
  149. 149. Bounding the tree-growing part Goal: ignore tree-growing for analysis. 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 tree-growing part T searching part XSnT Allow only first n to be chosen T elements for tree growing. Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 9 / 15
  150. 150. Bounding the tree-growing part Goal: ignore tree-growing for analysis. 4 5 5 5 2 3 5 4 2 2 2 5 5 5 4 2 5 1 5 4 2 3 4 2 2 1 2 4 2 2 5 5 2 3 4 2 3 4 1 3 2 2 1 4 4 4 1 2 3 3 tree-growing part T searching part XSnT Allow only first n to be chosen T elements for tree growing. Problem: if a value occurs < k times in first nT elements, T not complete Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 9 / 15

×