SlideShare a Scribd company logo
1 of 222
Download to read offline
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Sedgewick’s analysis for classic Quicksort
Classic Quicksort:
Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 4 / 15
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys

More Related Content

More from Sebastian Wild

Dual-Pivot Quicksort - Asymmetries in Sorting
Dual-Pivot Quicksort - Asymmetries in SortingDual-Pivot Quicksort - Asymmetries in Sorting
Dual-Pivot Quicksort - Asymmetries in SortingSebastian Wild
 
Pivot Sampling in Dual-Pivot Quicksort
Pivot Sampling in Dual-Pivot QuicksortPivot Sampling in Dual-Pivot Quicksort
Pivot Sampling in Dual-Pivot QuicksortSebastian Wild
 
Analysis of branch misses in Quicksort
Analysis of branch misses in QuicksortAnalysis of branch misses in Quicksort
Analysis of branch misses in QuicksortSebastian Wild
 
Quickselect Under Yaroslavskiy's Dual Pivoting Algorithm
Quickselect Under Yaroslavskiy's Dual Pivoting AlgorithmQuickselect Under Yaroslavskiy's Dual Pivoting Algorithm
Quickselect Under Yaroslavskiy's Dual Pivoting AlgorithmSebastian Wild
 
Engineering Java 7's Dual Pivot Quicksort Using MaLiJAn
Engineering Java 7's Dual Pivot Quicksort Using MaLiJAnEngineering Java 7's Dual Pivot Quicksort Using MaLiJAn
Engineering Java 7's Dual Pivot Quicksort Using MaLiJAnSebastian Wild
 
Average Case Analysis of Java 7’s Dual Pivot Quicksort
Average Case Analysis of Java 7’s Dual Pivot QuicksortAverage Case Analysis of Java 7’s Dual Pivot Quicksort
Average Case Analysis of Java 7’s Dual Pivot QuicksortSebastian Wild
 

More from Sebastian Wild (6)

Dual-Pivot Quicksort - Asymmetries in Sorting
Dual-Pivot Quicksort - Asymmetries in SortingDual-Pivot Quicksort - Asymmetries in Sorting
Dual-Pivot Quicksort - Asymmetries in Sorting
 
Pivot Sampling in Dual-Pivot Quicksort
Pivot Sampling in Dual-Pivot QuicksortPivot Sampling in Dual-Pivot Quicksort
Pivot Sampling in Dual-Pivot Quicksort
 
Analysis of branch misses in Quicksort
Analysis of branch misses in QuicksortAnalysis of branch misses in Quicksort
Analysis of branch misses in Quicksort
 
Quickselect Under Yaroslavskiy's Dual Pivoting Algorithm
Quickselect Under Yaroslavskiy's Dual Pivoting AlgorithmQuickselect Under Yaroslavskiy's Dual Pivoting Algorithm
Quickselect Under Yaroslavskiy's Dual Pivoting Algorithm
 
Engineering Java 7's Dual Pivot Quicksort Using MaLiJAn
Engineering Java 7's Dual Pivot Quicksort Using MaLiJAnEngineering Java 7's Dual Pivot Quicksort Using MaLiJAn
Engineering Java 7's Dual Pivot Quicksort Using MaLiJAn
 
Average Case Analysis of Java 7’s Dual Pivot Quicksort
Average Case Analysis of Java 7’s Dual Pivot QuicksortAverage Case Analysis of Java 7’s Dual Pivot Quicksort
Average Case Analysis of Java 7’s Dual Pivot Quicksort
 

Recently uploaded

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 

Recently uploaded (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 

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

  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. Sedgewick’s analysis for classic Quicksort Classic Quicksort: Sebastian Wild Quicksort Is Optimal For Many Equal Keys 2018-01-08 4 / 15
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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