SlideShare a Scribd company logo
Quicksort with Equal Keys
Sebastian Wild
wild@cs.uni-kl.de
based on joint work with
Martin Aumüller, Martin Dietzfelbinger,
Conrado Martínez, and Markus Nebel
Data Structures
and Advanced Models of
Computation on Big Data
Dagstuhl Seminar 16 101
Sebastian Wild Quicksort with Equal Keys 2016-03-07 1 / 12
Motivation
Practical Dimension:
solve togetherness problem
e.g. SQL’s GROUP BY clause
preprocessing to remove dups
Theoretical Dimension:
many equals lower entropy
We should be able to sort faster!
Academic Dimension:
Open Problem of Sedgewick & Bentley:
Is Quicksort with median-of-k
entropy-optimal for k → ∞?
Personal Dimension:
This is my tenth talk on Quicksort ...
Equal Keys on my wishlist since 2012
Why Equal Keys?
Sebastian Wild Quicksort with Equal Keys 2016-03-07 2 / 12
Motivation
Practical Dimension:
solve togetherness problem
e.g. SQL’s GROUP BY clause
preprocessing to remove dups
Theoretical Dimension:
many equals lower entropy
We should be able to sort faster!
Academic Dimension:
Open Problem of Sedgewick & Bentley:
Is Quicksort with median-of-k
entropy-optimal for k → ∞?
Personal Dimension:
This is my tenth talk on Quicksort ...
Equal Keys on my wishlist since 2012
Why Equal Keys?
Sebastian Wild Quicksort with Equal Keys 2016-03-07 2 / 12
Motivation
Practical Dimension:
solve togetherness problem
e.g. SQL’s GROUP BY clause
preprocessing to remove dups
Theoretical Dimension:
many equals lower entropy
We should be able to sort faster!
Academic Dimension:
Open Problem of Sedgewick & Bentley:
Is Quicksort with median-of-k
entropy-optimal for k → ∞?
Personal Dimension:
This is my tenth talk on Quicksort ...
Equal Keys on my wishlist since 2012
Why Equal Keys?
Sebastian Wild Quicksort with Equal Keys 2016-03-07 2 / 12
Motivation
Practical Dimension:
solve togetherness problem
e.g. SQL’s GROUP BY clause
preprocessing to remove dups
Theoretical Dimension:
many equals lower entropy
We should be able to sort faster!
Academic Dimension:
Open Problem of Sedgewick & Bentley:
Is Quicksort with median-of-k
entropy-optimal for k → ∞?
Personal Dimension:
This is my tenth talk on Quicksort ...
Equal Keys on my wishlist since 2012
Why Equal Keys?
Sebastian Wild Quicksort with Equal Keys 2016-03-07 2 / 12
Motivation
Practical Dimension:
solve togetherness problem
e.g. SQL’s GROUP BY clause
preprocessing to remove dups
Theoretical Dimension:
many equals lower entropy
We should be able to sort faster!
Academic Dimension:
Open Problem of Sedgewick & Bentley:
Is Quicksort with median-of-k
entropy-optimal for k → ∞?
Personal Dimension:
This is my tenth talk on Quicksort ...
Equal Keys on my wishlist since 2012
Why Equal Keys?
Sebastian Wild Quicksort with Equal Keys 2016-03-07 2 / 12
Previous Work
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 with Equal Keys 2016-03-07 3 / 12
Previous Work
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
general-purpose sorting method suitable for use on computers. The algorithm has
a rich history: many modifications have been suggested to improve its perfor-
mance, and exact formulas have been derived describing the time and spaceSebastian Wild Quicksort with Equal Keys 2016-03-07 3 / 12
Previous Work
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
general-purpose sorting method suitable for use on computers. The algorithm has
a rich history: many modifications have been suggested to improve its perfor-
mance, and exact formulas have been derived describing the time and space
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 with Equal Keys 2016-03-07 3 / 12
Previous Work
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
general-purpose sorting method suitable for use on computers. The algorithm has
a rich history: many modifications have been suggested to improve its perfor-
mance, and exact formulas have been derived describing the time and space
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
Introduction
The expected depth of the number r in the set of binary search trees formed from allSebastian Wild Quicksort with Equal Keys 2016-03-07 3 / 12
Previous Work
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
general-purpose sorting method suitable for use on computers. The algorithm has
a rich history: many modifications have been suggested to improve its perfor-
mance, and exact formulas have been derived describing the time and space
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
Introduction
The expected depth of the number r in the set of binary search trees formed from all
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
Communicated by H. Prodinger
Sebastian Wild Quicksort with Equal Keys 2016-03-07 3 / 12
Previous Work
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
general-purpose sorting method suitable for use on computers. The algorithm has
a rich history: many modifications have been suggested to improve its perfor-
mance, and exact formulas have been derived describing the time and space
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
Introduction
The expected depth of the number r in the set of binary search trees formed from all
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
Communicated by H. Prodinger
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
Random sequences from alphabet {1, . . . , r} are examined where repeated letters are allowed. Binary search trees are
formed from these, and the average left-going depth of the first 1 is found. Next, the right-going depth of the first r is
examined, and finally a merge (or ‘shuffle’) operator is used to obtain the average depth of an arbitrary node, which canSebastian Wild Quicksort with Equal Keys 2016-03-07 3 / 12
Previous Work
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
general-purpose sorting method suitable for use on computers. The algorithm has
a rich history: many modifications have been suggested to improve its perfor-
mance, and exact formulas have been derived describing the time and space
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
Introduction
The expected depth of the number r in the set of binary search trees formed from all
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
Communicated by H. Prodinger
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
Random sequences from alphabet {1, . . . , r} are examined where repeated letters are allowed. Binary search trees are
formed from these, and the average left-going depth of the first 1 is found. Next, the right-going depth of the first r is
examined, and finally a merge (or ‘shuffle’) operator is used to obtain the average depth of an arbitrary node, which canSebastian Wild Quicksort with Equal Keys 2016-03-07 3 / 12
Previous Work
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
general-purpose sorting method suitable for use on computers. The algorithm has
a rich history: many modifications have been suggested to improve its perfor-
mance, and exact formulas have been derived describing the time and space
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
Introduction
The expected depth of the number r in the set of binary search trees formed from all
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
Communicated by H. Prodinger
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
Random sequences from alphabet {1, . . . , r} are examined where repeated letters are allowed. Binary search trees are
formed from these, and the average left-going depth of the first 1 is found. Next, the right-going depth of the first r is
examined, and finally a merge (or ‘shuffle’) operator is used to obtain the average depth of an arbitrary node, which can
All these works only consider basic Quicksort:
No sampling to choose pivots.
No multi-way partitioning.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 3 / 12
Input Models
Random-Permutation Model
no duplicates
1 1, . . . , n, randomly permuted
Parameters: n
Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
Input Models
Random-Permutation Model
no duplicates
1 1, . . . , n, randomly permuted
Parameters: n
Random u-ary Word Model
1 random choice from {1, . . . , u}n
Parameters: n, u
My claim: u-ary words most natural model ...
in particular in i.i.d. interpretation!
All previous works use combinatorial detour
Stochastic point of view provides shortcut!
Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
Input Models
Random-Permutation Model
no duplicates
1 1, . . . , n, randomly permuted
2 n elem. i.i.d. uniform in (0, 1)
Parameters: n
Random u-ary Word Model
1 random choice from {1, . . . , u}n
2 n elem. i.i.d. uniform in {1, . . . , u}
Parameters: n, u
My claim: u-ary words most natural model ...
in particular in i.i.d. interpretation!
All previous works use combinatorial detour
Stochastic point of view provides shortcut!
Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
Input Models
Random-Permutation Model
no duplicates
1 1, . . . , n, randomly permuted
2 n elem. i.i.d. uniform in (0, 1)
Parameters: n
Random u-ary Word Model
1 random choice from {1, . . . , u}n
2 n elem. i.i.d. uniform in {1, . . . , u}
Parameters: n, u
cont. disc.
My claim: u-ary words most natural model ...
in particular in i.i.d. interpretation!
All previous works use combinatorial detour
Stochastic point of view provides shortcut!
Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
Input Models
Random-Permutation Model
no duplicates
1 1, . . . , n, randomly permuted
2 n elem. i.i.d. uniform in (0, 1)
Parameters: n
Random u-ary Word Model
1 random choice from {1, . . . , u}n
2 n elem. i.i.d. uniform in {1, . . . , u}
Parameters: n, u
Multiset-Permutation Model
randomly permuted multiset
xi copies of i, i = 1, . . . , u
Parameters: u; x1, . . . , xuset
multiset
cont. disc.
My claim: u-ary words most natural model ...
in particular in i.i.d. interpretation!
All previous works use combinatorial detour
Stochastic point of view provides shortcut!
Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
Input Models
Random-Permutation Model
no duplicates
1 1, . . . , n, randomly permuted
2 n elem. i.i.d. uniform in (0, 1)
Parameters: n
Random u-ary Word Model
1 random choice from {1, . . . , u}n
2 n elem. i.i.d. uniform in {1, . . . , u}
Parameters: n, u
Multiset-Permutation Model
randomly permuted multiset
xi copies of i, i = 1, . . . , u
Parameters: u; x1, . . . , xuset
multiset aver
age
cont. disc.
My claim: u-ary words most natural model ...
in particular in i.i.d. interpretation!
All previous works use combinatorial detour
Stochastic point of view provides shortcut!
Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
Input Models
Random-Permutation Model
no duplicates
1 1, . . . , n, randomly permuted
2 n elem. i.i.d. uniform in (0, 1)
Parameters: n
Random u-ary Word Model
1 random choice from {1, . . . , u}n
2 n elem. i.i.d. uniform in {1, . . . , u}
Parameters: n, u
Multiset-Permutation Model
randomly permuted multiset
xi copies of i, i = 1, . . . , u
Parameters: u; x1, . . . , xuset
multiset aver
age
cont. disc.
hard to
analyze
My claim: u-ary words most natural model ...
in particular in i.i.d. interpretation!
All previous works use combinatorial detour
Stochastic point of view provides shortcut!
Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
Input Models
Random-Permutation Model
no duplicates
1 1, . . . , n, randomly permuted
2 n elem. i.i.d. uniform in (0, 1)
Parameters: n
Random u-ary Word Model
1 random choice from {1, . . . , u}n
2 n elem. i.i.d. uniform in {1, . . . , u}
Parameters: n, u
Multiset-Permutation Model
randomly permuted multiset
xi copies of i, i = 1, . . . , u
Parameters: u; x1, . . . , xuset
multiset aver
age
cont. disc.
hard to
analyze
My claim: u-ary words most natural model ...
in particular in i.i.d. interpretation!
All previous works use combinatorial detour
Stochastic point of view provides shortcut!
Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
Input Models
Random-Permutation Model
no duplicates
1 1, . . . , n, randomly permuted
2 n elem. i.i.d. uniform in (0, 1)
Parameters: n
Random u-ary Word Model
1 random choice from {1, . . . , u}n
2 n elem. i.i.d. uniform in {1, . . . , u}
Parameters: n, u
Multiset-Permutation Model
randomly permuted multiset
xi copies of i, i = 1, . . . , u
Parameters: u; x1, . . . , xuset
multiset aver
age
cont. disc.
hard to
analyze
My claim: u-ary words most natural model ...
in particular in i.i.d. interpretation!
All previous works use combinatorial detour
Stochastic point of view provides shortcut!
Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
Setup
Assumptions:
1 Input: U1, . . . , Un, i.i.d. uniform in {1, . . . , u}.
2 fat-pivot partitioning < P P P P > P
recursive call recursive callall duplicates of pivots removed
subproblems again random u-ary words, (with smaller u and n)
3 Cost: # ternary comparisons
(extensions possible)
Generalized Quicksort:
s-way partitioning: divide into s segments
pivot sampling: parameter t = (t1, . . . , ts)
median-of-(2t + 1) t = (t, t)
asymmetric sampling allowed
Example:
s = 3 and t = (1, 2, 3)
P1 P2
t1 t2 t3
2nd
and 5th
from sample of 8.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 5 / 12
Setup
Assumptions:
1 Input: U1, . . . , Un, i.i.d. uniform in {1, . . . , u}.
2 fat-pivot partitioning < P P P P > P
recursive call recursive callall duplicates of pivots removed
subproblems again random u-ary words, (with smaller u and n)
3 Cost: # ternary comparisons
(extensions possible)
Generalized Quicksort:
s-way partitioning: divide into s segments
pivot sampling: parameter t = (t1, . . . , ts)
median-of-(2t + 1) t = (t, t)
asymmetric sampling allowed
Example:
s = 3 and t = (1, 2, 3)
P1 P2
t1 t2 t3
2nd
and 5th
from sample of 8.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 5 / 12
Setup
Assumptions:
1 Input: U1, . . . , Un, i.i.d. uniform in {1, . . . , u}.
2 fat-pivot partitioning < P P P P > P
recursive call recursive callall duplicates of pivots removed
subproblems again random u-ary words, (with smaller u and n)
3 Cost: # ternary comparisons
(extensions possible)
Generalized Quicksort:
s-way partitioning: divide into s segments
pivot sampling: parameter t = (t1, . . . , ts)
median-of-(2t + 1) t = (t, t)
asymmetric sampling allowed
Example:
s = 3 and t = (1, 2, 3)
P1 P2
t1 t2 t3
2nd
and 5th
from sample of 8.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 5 / 12
Setup
Assumptions:
1 Input: U1, . . . , Un, i.i.d. uniform in {1, . . . , u}.
2 fat-pivot partitioning < P P P P > P
recursive call recursive callall duplicates of pivots removed
subproblems again random u-ary words, (with smaller u and n)
3 Cost: # ternary comparisons
(extensions possible)
Generalized Quicksort:
s-way partitioning: divide into s segments
pivot sampling: parameter t = (t1, . . . , ts)
median-of-(2t + 1) t = (t, t)
asymmetric sampling allowed
Example:
s = 3 and t = (1, 2, 3)
P1 P2
t1 t2 t3
2nd
and 5th
from sample of 8.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 5 / 12
Setup
Assumptions:
1 Input: U1, . . . , Un, i.i.d. uniform in {1, . . . , u}.
2 fat-pivot partitioning < P P P P > P
recursive call recursive callall duplicates of pivots removed
subproblems again random u-ary words, (with smaller u and n)
3 Cost: # ternary comparisons
(extensions possible)
Generalized Quicksort:
s-way partitioning: divide into s segments
pivot sampling: parameter t = (t1, . . . , ts)
median-of-(2t + 1) t = (t, t)
asymmetric sampling allowed
Example:
s = 3 and t = (1, 2, 3)
P1 P2
t1 t2 t3
2nd
and 5th
from sample of 8.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 5 / 12
Setup
Assumptions:
1 Input: U1, . . . , Un, i.i.d. uniform in {1, . . . , u}.
2 fat-pivot partitioning < P P P P > P
recursive call recursive callall duplicates of pivots removed
subproblems again random u-ary words, (with smaller u and n)
3 Cost: # ternary comparisons
(extensions possible)
Generalized Quicksort:
s-way partitioning: divide into s segments
pivot sampling: parameter t = (t1, . . . , ts)
median-of-(2t + 1) t = (t, t)
asymmetric sampling allowed
Example:
s = 3 and t = (1, 2, 3)
P1 P2
t1 t2 t3
2nd
and 5th
from sample of 8.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 5 / 12
Setup
Assumptions:
1 Input: U1, . . . , Un, i.i.d. uniform in {1, . . . , u}.
2 fat-pivot partitioning < P P P P > P
recursive call recursive callall duplicates of pivots removed
subproblems again random u-ary words, (with smaller u and n)
3 Cost: # ternary comparisons
(extensions possible)
Generalized Quicksort:
s-way partitioning: divide into s segments
pivot sampling: parameter t = (t1, . . . , ts)
median-of-(2t + 1) t = (t, t)
asymmetric sampling allowed
Example:
s = 3 and t = (1, 2, 3)
P1 P2
t1 t2 t3
2nd
and 5th
from sample of 8.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 5 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
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 with Equal Keys 2016-03-07 6 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2)
4 2 1 3 3 5 4 4 3 5 2
Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2)
4 2 1 3 3 5 4 4 3 5 2
Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2)
4 2 1 3 3 5 4 4 3 5 2
Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2)
4 2 1 3 3 5 4 4 3 5 2
2 1 2 4 5 4 4 533 3
Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2)
4 2 1 3 3 5 4 4 3 5 2
2 1 2 4 5 4 4 533 3
Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2)
4 2 1 3 3 5 4 4 3 5 2
2 1 2 4 5 4 4 533 3
Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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
Analyze search trees instead of Quicksort.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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
Analyze search trees instead of Quicksort.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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
Analyze search trees instead of Quicksort.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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
Analyze search trees instead of Quicksort.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
Fringe-Balanced Trees
Fringe-Balanced Search Trees:
Leaves have buffer for elements, to emulate pivot sampling
Median-of-5 Quicksort t = (2, 2) 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
Analyze search trees instead of Quicksort.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
Observation: T becomes stationary after 1 insert of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
(w = 1)
Observation: T becomes stationary after w inserts of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
(w = 1)
Observation: T becomes stationary after w inserts of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
(w = 1)
tree-growing part T
Observation: T becomes stationary after w inserts of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
(w = 1)
tree-growing part T searching part XS
Observation: T becomes stationary after w inserts of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
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
(w = 1)
tree-growing part T searching part XS
Observation: T becomes stationary after w inserts of each value!
with leaf-buffer size w
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 with Equal Keys 2016-03-07 8 / 12
Bounding Tree-Growing Parts
We ignore tree-growing in analysis have to make that part short.
Allow first nT = n2/3
elements to build T.
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 XS
nT
Input is degenerate if a value occurs < w times in first nT elements.
T not complete after nT inserts ...
Have to make this happen rarely.
By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4
)
building T costs nT · u = O(n1−ε
)
Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε
)
αu = expected search cost in random T
error term: covers tree-growing, sorting samples, degenerate inputs
Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
Bounding Tree-Growing Parts
We ignore tree-growing in analysis have to make that part short.
Allow first nT = n2/3
elements to build T.
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 XS
nT
Input is degenerate if a value occurs < w times in first nT elements.
T not complete after nT inserts ...
Have to make this happen rarely.
By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4
)
building T costs nT · u = O(n1−ε
)
Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε
)
αu = expected search cost in random T
error term: covers tree-growing, sorting samples, degenerate inputs
Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
Bounding Tree-Growing Parts
We ignore tree-growing in analysis have to make that part short.
Allow first nT = n2/3
elements to build T.
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 XS
nT
Input is degenerate if a value occurs < w times in first nT elements.
T not complete after nT inserts ...
Have to make this happen rarely.
By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4
)
building T costs nT · u = O(n1−ε
)
Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε
)
αu = expected search cost in random T
error term: covers tree-growing, sorting samples, degenerate inputs
Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
Bounding Tree-Growing Parts
We ignore tree-growing in analysis have to make that part short.
Allow first nT = n2/3
elements to build T.
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 XS
nT
Input is degenerate if a value occurs < w times in first nT elements.
T not complete after nT inserts ...
Have to make this happen rarely.
By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4
)
building T costs nT · u = O(n1−ε
)
Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε
)
αu = expected search cost in random T
error term: covers tree-growing, sorting samples, degenerate inputs
Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
Bounding Tree-Growing Parts
We ignore tree-growing in analysis have to make that part short.
Allow first nT = n2/3
elements to build T.
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 XS
nT
Input is degenerate if a value occurs < w times in first nT elements.
T not complete after nT inserts ...
Have to make this happen rarely.
By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4
)
building T costs nT · u = O(n1−ε
)
Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε
)
αu = expected search cost in random T
error term: covers tree-growing, sorting samples, degenerate inputs
Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
Bounding Tree-Growing Parts
We ignore tree-growing in analysis have to make that part short.
Allow first nT = n2/3
elements to build T.
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 XS
nT
Input is degenerate if a value occurs < w times in first nT elements.
T not complete after nT inserts ...
Have to make this happen rarely.
By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4
)
building T costs nT · u = O(n1−ε
)
Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε
)
αu = expected search cost in random T
error term: covers tree-growing, sorting samples, degenerate inputs
Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
Bounding Tree-Growing Parts
We ignore tree-growing in analysis have to make that part short.
Allow first nT = n2/3
elements to build T.
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 XS
nT
Input is degenerate if a value occurs < w times in first nT elements.
T not complete after nT inserts ...
Have to make this happen rarely.
By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4
)
building T costs nT · u = O(n1−ε
)
Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε
)
αu = expected search cost in random T
error term: covers tree-growing, sorting samples, degenerate inputs
Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
Bounding Tree-Growing Parts
We ignore tree-growing in analysis have to make that part short.
Allow first nT = n2/3
elements to build T.
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 XS
nT
Input is degenerate if a value occurs < w times in first nT elements.
T not complete after nT inserts ...
Have to make this happen rarely.
By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4
)
building T costs nT · u = O(n1−ε
)
Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε
)
αu = expected search cost in random T
error term: covers tree-growing, sorting samples, degenerate inputs
Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
Bounding Tree-Growing Parts
We ignore tree-growing in analysis have to make that part short.
Allow first nT = n2/3
elements to build T.
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 XS
nT
Input is degenerate if a value occurs < w times in first nT elements.
T not complete after nT inserts ...
Have to make this happen rarely.
By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4
)
building T costs nT · u = O(n1−ε
)
Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε
)
αu = expected search cost in random T
error term: covers tree-growing, sorting samples, degenerate inputs
Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
Bounding Tree-Growing Parts
We ignore tree-growing in analysis have to make that part short.
Allow first nT = n2/3
elements to build T.
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 XS
nT
Input is degenerate if a value occurs < w times in first nT elements.
T not complete after nT inserts ...
Have to make this happen rarely.
By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4
)
building T costs nT · u = O(n1−ε
)
Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε
)
αu = expected search cost in random T
error term: covers tree-growing, sorting samples, degenerate inputs
Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
Bounding Tree-Growing Parts
We ignore tree-growing in analysis have to make that part short.
Allow first nT = n2/3
elements to build T.
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 XS
nT
Input is degenerate if a value occurs < w times in first nT elements.
T not complete after nT inserts ...
Have to make this happen rarely.
By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4
)
building T costs nT · u = O(n1−ε
)
Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε
)
αu = expected search cost in random T
error term: covers tree-growing, sorting samples, degenerate inputs
Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
Search Costs
Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation.
αu =
1
u
u
v=1
cost of searching v in T (u · αu = path length of T)
1 Easy case: t = (0, 0) ordinary BST, w = 1
no duplicates in tree
T is BST under random permutation model Allen & Munro 1978:
Self-Organizing Binary Search Trees
2 General t = (t1, . . . , ts):
duplicates inside leaves (during construction) 3 3
for s 3: duplicates in same internal node possible
= random permutation
But: can set up a (messy) recurrence for αu
asymptotic solution by Continuous Master Theorem
Roura 2001:
Improved Master Theorems for
Divide-and-Conquer Recurrences
Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
Search Costs
Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation.
αu =
1
u
u
v=1
cost of searching v in T (u · αu = path length of T)
1 Easy case: t = (0, 0) ordinary BST, w = 1
no duplicates in tree
T is BST under random permutation model Allen & Munro 1978:
Self-Organizing Binary Search Trees
2 General t = (t1, . . . , ts):
duplicates inside leaves (during construction) 3 3
for s 3: duplicates in same internal node possible
= random permutation
But: can set up a (messy) recurrence for αu
asymptotic solution by Continuous Master Theorem
Roura 2001:
Improved Master Theorems for
Divide-and-Conquer Recurrences
Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
Search Costs
Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation.
αu =
1
u
u
v=1
cost of searching v in T (u · αu = path length of T)
1 Easy case: t = (0, 0) ordinary BST, w = 1
no duplicates in tree
T is BST under random permutation model Allen & Munro 1978:
Self-Organizing Binary Search Trees
2 General t = (t1, . . . , ts):
duplicates inside leaves (during construction) 3 3
for s 3: duplicates in same internal node possible
= random permutation
But: can set up a (messy) recurrence for αu
asymptotic solution by Continuous Master Theorem
Roura 2001:
Improved Master Theorems for
Divide-and-Conquer Recurrences
Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
Search Costs
Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation.
αu =
1
u
u
v=1
cost of searching v in T (u · αu = path length of T)
1 Easy case: t = (0, 0) ordinary BST, w = 1
no duplicates in tree
T is BST under random permutation model Allen & Munro 1978:
Self-Organizing Binary Search Trees
2 General t = (t1, . . . , ts):
duplicates inside leaves (during construction) 3 3
for s 3: duplicates in same internal node possible
= random permutation
But: can set up a (messy) recurrence for αu
asymptotic solution by Continuous Master Theorem
Roura 2001:
Improved Master Theorems for
Divide-and-Conquer Recurrences
Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
Search Costs
Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation.
αu =
1
u
u
v=1
cost of searching v in T (u · αu = path length of T)
1 Easy case: t = (0, 0) ordinary BST, w = 1
no duplicates in tree
T is BST under random permutation model Allen & Munro 1978:
Self-Organizing Binary Search Trees
2 General t = (t1, . . . , ts):
duplicates inside leaves (during construction) 3 3
for s 3: duplicates in same internal node possible
= random permutation
But: can set up a (messy) recurrence for αu
asymptotic solution by Continuous Master Theorem
Roura 2001:
Improved Master Theorems for
Divide-and-Conquer Recurrences
Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
Search Costs
Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation.
αu =
1
u
u
v=1
cost of searching v in T (u · αu = path length of T)
1 Easy case: t = (0, 0) ordinary BST, w = 1
no duplicates in tree
T is BST under random permutation model Allen & Munro 1978:
Self-Organizing Binary Search Trees
αu = 2 1 + 1
u
Hu − 3 = 2 ln(u) ± O(1)
2 General t = (t1, . . . , ts):
duplicates inside leaves (during construction) 3 3
for s 3: duplicates in same internal node possible
= random permutation
But: can set up a (messy) recurrence for αu
asymptotic solution by Continuous Master Theorem
Roura 2001:
Improved Master Theorems for
Divide-and-Conquer Recurrences
Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
Search Costs
Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation.
αu =
1
u
u
v=1
cost of searching v in T (u · αu = path length of T)
1 Easy case: t = (0, 0) ordinary BST, w = 1
no duplicates in tree
T is BST under random permutation model Allen & Munro 1978:
Self-Organizing Binary Search Trees
αu = 2 1 + 1
u
Hu − 3 = 2 ln(u) ± O(1)
2 General t = (t1, . . . , ts):
duplicates inside leaves (during construction) 3 3
for s 3: duplicates in same internal node possible
= random permutation
But: can set up a (messy) recurrence for αu
asymptotic solution by Continuous Master Theorem
Roura 2001:
Improved Master Theorems for
Divide-and-Conquer Recurrences
Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
Search Costs
Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation.
αu =
1
u
u
v=1
cost of searching v in T (u · αu = path length of T)
1 Easy case: t = (0, 0) ordinary BST, w = 1
no duplicates in tree
T is BST under random permutation model Allen & Munro 1978:
Self-Organizing Binary Search Trees
αu = 2 1 + 1
u
Hu − 3 = 2 ln(u) ± O(1)
2 General t = (t1, . . . , ts):
duplicates inside leaves (during construction) 3 3
for s 3: duplicates in same internal node possible
= random permutation
But: can set up a (messy) recurrence for αu
asymptotic solution by Continuous Master Theorem
Roura 2001:
Improved Master Theorems for
Divide-and-Conquer Recurrences
Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
Search Costs
Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation.
αu =
1
u
u
v=1
cost of searching v in T (u · αu = path length of T)
1 Easy case: t = (0, 0) ordinary BST, w = 1
no duplicates in tree
T is BST under random permutation model Allen & Munro 1978:
Self-Organizing Binary Search Trees
αu = 2 1 + 1
u
Hu − 3 = 2 ln(u) ± O(1)
2 General t = (t1, . . . , ts):
duplicates inside leaves (during construction) 3 3
1 2 4
for s 3: duplicates in same internal node possible
= random permutation
But: can set up a (messy) recurrence for αu
asymptotic solution by Continuous Master Theorem
Roura 2001:
Improved Master Theorems for
Divide-and-Conquer Recurrences
Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
Search Costs
Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation.
αu =
1
u
u
v=1
cost of searching v in T (u · αu = path length of T)
1 Easy case: t = (0, 0) ordinary BST, w = 1
no duplicates in tree
T is BST under random permutation model Allen & Munro 1978:
Self-Organizing Binary Search Trees
αu = 2 1 + 1
u
Hu − 3 = 2 ln(u) ± O(1)
2 General t = (t1, . . . , ts):
duplicates inside leaves (during construction) 3 3
1 2 4
for s 3: duplicates in same internal node possible
= random permutation
But: can set up a (messy) recurrence for αu
asymptotic solution by Continuous Master Theorem
Roura 2001:
Improved Master Theorems for
Divide-and-Conquer Recurrences
Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
Search Costs
Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation.
αu =
1
u
u
v=1
cost of searching v in T (u · αu = path length of T)
1 Easy case: t = (0, 0) ordinary BST, w = 1
no duplicates in tree
T is BST under random permutation model Allen & Munro 1978:
Self-Organizing Binary Search Trees
αu = 2 1 + 1
u
Hu − 3 = 2 ln(u) ± O(1)
2 General t = (t1, . . . , ts):
duplicates inside leaves (during construction) 3 3
1 2 4
for s 3: duplicates in same internal node possible
= random permutation
But: can set up a (messy) recurrence for αu
asymptotic solution by Continuous Master Theorem
Roura 2001:
Improved Master Theorems for
Divide-and-Conquer Recurrences
Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
Search Costs
Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation.
αu =
1
u
u
v=1
cost of searching v in T (u · αu = path length of T)
1 Easy case: t = (0, 0) ordinary BST, w = 1
no duplicates in tree
T is BST under random permutation model Allen & Munro 1978:
Self-Organizing Binary Search Trees
αu = 2 1 + 1
u
Hu − 3 = 2 ln(u) ± O(1)
2 General t = (t1, . . . , ts):
duplicates inside leaves (during construction) 3 3
1 2 4
for s 3: duplicates in same internal node possible
= random permutation
But: can set up a (messy) recurrence for αu
asymptotic solution by Continuous Master Theorem
Roura 2001:
Improved Master Theorems for
Divide-and-Conquer Recurrences
Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
1 2 3 4
3
1
2
4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
1 2 3 4
3
1
2
4
¯a = 2.4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
1 2 3 4
3
1
2
4
¯a = 2.4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
1 2 3 4
3
1
2
4
¯a = 2.4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
1 2 3 4
3
1
2
4
¯a = 2.4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
1 2 3 4
3
1
2
4
¯a = 2.4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
1 2 3 4
3
1
2
4
¯a = 2.4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
1 2 3 4
3
1
2
4
¯a = 2.4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
1 2 3 4
3
1
2
4
¯a = 2.4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Results deceptively similar! (derivation isn’t)
Same speedup from sampling and multi-way partitioning.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Result
Search costs in T: αu =
¯a
H
ln(u) ± O(1) u → ∞
H =
s
r=1
tr + 1
k + 1
Hk+1 − Htr+1
k = sample size
¯a = avg. search costs inside node 1 2 3 4
1 2 3 4
3
1
2
4
¯a = 2.4
(¯a = 1 for binary trees)
Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε
) u = O(n1/4)
Time to put the pieces together!
Quicksort Costs
u-ary words: E[Cn,u] = ¯a
H n ln(u) ± O(n) u = ω(1), u = O(n1/4
)
Permutations: E[Cn] = ¯a
H n ln(n) ± O(n)
Results deceptively similar! (derivation isn’t)
Same speedup from sampling and multi-way partitioning.
Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
Conclusion
Findings
First analysis of generalized Quicksort (sampling & multi-way) on equal keys.
Limitations:
restricted range for universe size: u = ω(1) and u = O(n1/3−ε
)
currently only stateless cost measures
Partial Answer to conjecture of Sedgewick & Bentley:
Median-of-k Quicksort approaches lower bound for k → ∞ ... for uniform distribution.
Finally cleared the item from my to-do list
Future Work
other discrete distributions expected-profile model
better asymptotic approximation for αu
Sebastian Wild Quicksort with Equal Keys 2016-03-07 12 / 12
Conclusion
Findings
First analysis of generalized Quicksort (sampling & multi-way) on equal keys.
Limitations:
restricted range for universe size: u = ω(1) and u = O(n1/3−ε
)
currently only stateless cost measures
Partial Answer to conjecture of Sedgewick & Bentley:
Median-of-k Quicksort approaches lower bound for k → ∞ ... for uniform distribution.
Finally cleared the item from my to-do list
Future Work
other discrete distributions expected-profile model
better asymptotic approximation for αu
Sebastian Wild Quicksort with Equal Keys 2016-03-07 12 / 12
Conclusion
Findings
First analysis of generalized Quicksort (sampling & multi-way) on equal keys.
Limitations:
restricted range for universe size: u = ω(1) and u = O(n1/3−ε
)
currently only stateless cost measures
Partial Answer to conjecture of Sedgewick & Bentley:
Median-of-k Quicksort approaches lower bound for k → ∞ ... for uniform distribution.
Finally cleared the item from my to-do list
Future Work
other discrete distributions expected-profile model
better asymptotic approximation for αu
Sebastian Wild Quicksort with Equal Keys 2016-03-07 12 / 12
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys
Quicksort with Equal Keys

More Related Content

Similar to Quicksort with Equal Keys

final seminar
final seminarfinal seminar
final seminar
AMIT KUMAR
 
A survey paper on sequence pattern mining with incremental
A survey paper on sequence pattern mining with incrementalA survey paper on sequence pattern mining with incremental
A survey paper on sequence pattern mining with incremental
Alexander Decker
 
A survey paper on sequence pattern mining with incremental
A survey paper on sequence pattern mining with incrementalA survey paper on sequence pattern mining with incremental
A survey paper on sequence pattern mining with incremental
Alexander Decker
 
Constructing Operating Systems and E-Commerce
Constructing Operating Systems and E-CommerceConstructing Operating Systems and E-Commerce
Constructing Operating Systems and E-Commerce
IJARIIT
 
The Smart Way To Invest in AI and ML_SFStartupDay
The Smart Way To Invest in AI and ML_SFStartupDayThe Smart Way To Invest in AI and ML_SFStartupDay
The Smart Way To Invest in AI and ML_SFStartupDay
Amazon Web Services
 
A minimization approach for two level logic synthesis using constrained depth...
A minimization approach for two level logic synthesis using constrained depth...A minimization approach for two level logic synthesis using constrained depth...
A minimization approach for two level logic synthesis using constrained depth...
IAEME Publication
 
What's "For Free" on Craigslist?
What's "For Free" on Craigslist? What's "For Free" on Craigslist?
What's "For Free" on Craigslist?
Josh Mayer
 
A Brief Overview On Frequent Pattern Mining Algorithms
A Brief Overview On Frequent Pattern Mining AlgorithmsA Brief Overview On Frequent Pattern Mining Algorithms
A Brief Overview On Frequent Pattern Mining Algorithms
Sara Alvarez
 
Atomate: a tool for rapid high-throughput computing and materials discovery
Atomate: a tool for rapid high-throughput computing and materials discoveryAtomate: a tool for rapid high-throughput computing and materials discovery
Atomate: a tool for rapid high-throughput computing and materials discovery
Anubhav Jain
 
A Case for E-Business
A Case for E-BusinessA Case for E-Business
A Case for E-Business
ijsrd.com
 
ast nearest neighbor search with keywords
ast nearest neighbor search with keywordsast nearest neighbor search with keywords
ast nearest neighbor search with keywords
swathi78
 
IA3_presentation.pptx
IA3_presentation.pptxIA3_presentation.pptx
IA3_presentation.pptx
KtonNguyn2
 
Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...
Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...
Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...
BRNSSPublicationHubI
 
Topic detecton by clustering and text mining
Topic detecton by clustering and text miningTopic detecton by clustering and text mining
Topic detecton by clustering and text mining
IRJET Journal
 
Vol 16 No 2 - July-December 2016
Vol 16 No 2 - July-December 2016Vol 16 No 2 - July-December 2016
Vol 16 No 2 - July-December 2016
ijcsbi
 
Introduction and Applications of Discrete Mathematics
Introduction and Applications of Discrete MathematicsIntroduction and Applications of Discrete Mathematics
Introduction and Applications of Discrete Mathematics
blaircomp2003
 
Implementation of Improved Apriori Algorithm on Large Dataset using Hadoop
Implementation of Improved Apriori Algorithm on Large Dataset using HadoopImplementation of Improved Apriori Algorithm on Large Dataset using Hadoop
Implementation of Improved Apriori Algorithm on Large Dataset using Hadoop
BRNSSPublicationHubI
 
Review Over Sequential Rule Mining
Review Over Sequential Rule MiningReview Over Sequential Rule Mining
Review Over Sequential Rule Mining
ijsrd.com
 
Machine Reading Using Neural Machines (talk at Microsoft Research Faculty Sum...
Machine Reading Using Neural Machines (talk at Microsoft Research Faculty Sum...Machine Reading Using Neural Machines (talk at Microsoft Research Faculty Sum...
Machine Reading Using Neural Machines (talk at Microsoft Research Faculty Sum...
Isabelle Augenstein
 
Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)
Ravi Okade
 

Similar to Quicksort with Equal Keys (20)

final seminar
final seminarfinal seminar
final seminar
 
A survey paper on sequence pattern mining with incremental
A survey paper on sequence pattern mining with incrementalA survey paper on sequence pattern mining with incremental
A survey paper on sequence pattern mining with incremental
 
A survey paper on sequence pattern mining with incremental
A survey paper on sequence pattern mining with incrementalA survey paper on sequence pattern mining with incremental
A survey paper on sequence pattern mining with incremental
 
Constructing Operating Systems and E-Commerce
Constructing Operating Systems and E-CommerceConstructing Operating Systems and E-Commerce
Constructing Operating Systems and E-Commerce
 
The Smart Way To Invest in AI and ML_SFStartupDay
The Smart Way To Invest in AI and ML_SFStartupDayThe Smart Way To Invest in AI and ML_SFStartupDay
The Smart Way To Invest in AI and ML_SFStartupDay
 
A minimization approach for two level logic synthesis using constrained depth...
A minimization approach for two level logic synthesis using constrained depth...A minimization approach for two level logic synthesis using constrained depth...
A minimization approach for two level logic synthesis using constrained depth...
 
What's "For Free" on Craigslist?
What's "For Free" on Craigslist? What's "For Free" on Craigslist?
What's "For Free" on Craigslist?
 
A Brief Overview On Frequent Pattern Mining Algorithms
A Brief Overview On Frequent Pattern Mining AlgorithmsA Brief Overview On Frequent Pattern Mining Algorithms
A Brief Overview On Frequent Pattern Mining Algorithms
 
Atomate: a tool for rapid high-throughput computing and materials discovery
Atomate: a tool for rapid high-throughput computing and materials discoveryAtomate: a tool for rapid high-throughput computing and materials discovery
Atomate: a tool for rapid high-throughput computing and materials discovery
 
A Case for E-Business
A Case for E-BusinessA Case for E-Business
A Case for E-Business
 
ast nearest neighbor search with keywords
ast nearest neighbor search with keywordsast nearest neighbor search with keywords
ast nearest neighbor search with keywords
 
IA3_presentation.pptx
IA3_presentation.pptxIA3_presentation.pptx
IA3_presentation.pptx
 
Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...
Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...
Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...
 
Topic detecton by clustering and text mining
Topic detecton by clustering and text miningTopic detecton by clustering and text mining
Topic detecton by clustering and text mining
 
Vol 16 No 2 - July-December 2016
Vol 16 No 2 - July-December 2016Vol 16 No 2 - July-December 2016
Vol 16 No 2 - July-December 2016
 
Introduction and Applications of Discrete Mathematics
Introduction and Applications of Discrete MathematicsIntroduction and Applications of Discrete Mathematics
Introduction and Applications of Discrete Mathematics
 
Implementation of Improved Apriori Algorithm on Large Dataset using Hadoop
Implementation of Improved Apriori Algorithm on Large Dataset using HadoopImplementation of Improved Apriori Algorithm on Large Dataset using Hadoop
Implementation of Improved Apriori Algorithm on Large Dataset using Hadoop
 
Review Over Sequential Rule Mining
Review Over Sequential Rule MiningReview Over Sequential Rule Mining
Review Over Sequential Rule Mining
 
Machine Reading Using Neural Machines (talk at Microsoft Research Faculty Sum...
Machine Reading Using Neural Machines (talk at Microsoft Research Faculty Sum...Machine Reading Using Neural Machines (talk at Microsoft Research Faculty Sum...
Machine Reading Using Neural Machines (talk at Microsoft Research Faculty Sum...
 
Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)
 

More from Sebastian Wild

Succint Data Structures for Range Minimum Problems
Succint Data Structures for Range Minimum ProblemsSuccint Data Structures for Range Minimum Problems
Succint Data Structures for Range Minimum Problems
Sebastian Wild
 
Entropy Trees & Range-Minimum Queries in Optimal Average-Case Space
Entropy Trees & Range-Minimum Queries in Optimal Average-Case SpaceEntropy Trees & Range-Minimum Queries in Optimal Average-Case Space
Entropy Trees & Range-Minimum Queries in Optimal Average-Case Space
Sebastian Wild
 
Sesquickselect: One and a half pivot for cache efficient selection
Sesquickselect: One and a half pivot for cache efficient selectionSesquickselect: One and a half pivot for cache efficient selection
Sesquickselect: One and a half pivot for cache efficient selection
Sebastian Wild
 
Average cost of QuickXsort with pivot sampling
Average cost of QuickXsort with pivot samplingAverage cost of QuickXsort with pivot sampling
Average cost of QuickXsort with pivot sampling
Sebastian Wild
 
Nearly-optimal mergesort: Fast, practical sorting methods that optimally adap...
Nearly-optimal mergesort: Fast, practical sorting methods that optimally adap...Nearly-optimal mergesort: Fast, practical sorting methods that optimally adap...
Nearly-optimal mergesort: Fast, practical sorting methods that optimally adap...
Sebastian Wild
 
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keysMedian-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
Sebastian Wild
 
Quicksort and Binary Search Trees
Quicksort and Binary Search TreesQuicksort and Binary Search Trees
Quicksort and Binary Search Trees
Sebastian Wild
 

More from Sebastian Wild (7)

Succint Data Structures for Range Minimum Problems
Succint Data Structures for Range Minimum ProblemsSuccint Data Structures for Range Minimum Problems
Succint Data Structures for Range Minimum Problems
 
Entropy Trees & Range-Minimum Queries in Optimal Average-Case Space
Entropy Trees & Range-Minimum Queries in Optimal Average-Case SpaceEntropy Trees & Range-Minimum Queries in Optimal Average-Case Space
Entropy Trees & Range-Minimum Queries in Optimal Average-Case Space
 
Sesquickselect: One and a half pivot for cache efficient selection
Sesquickselect: One and a half pivot for cache efficient selectionSesquickselect: One and a half pivot for cache efficient selection
Sesquickselect: One and a half pivot for cache efficient selection
 
Average cost of QuickXsort with pivot sampling
Average cost of QuickXsort with pivot samplingAverage cost of QuickXsort with pivot sampling
Average cost of QuickXsort with pivot sampling
 
Nearly-optimal mergesort: Fast, practical sorting methods that optimally adap...
Nearly-optimal mergesort: Fast, practical sorting methods that optimally adap...Nearly-optimal mergesort: Fast, practical sorting methods that optimally adap...
Nearly-optimal mergesort: Fast, practical sorting methods that optimally adap...
 
Median-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keysMedian-of-k Quicksort is optimal for many equal keys
Median-of-k Quicksort is optimal for many equal keys
 
Quicksort and Binary Search Trees
Quicksort and Binary Search TreesQuicksort and Binary Search Trees
Quicksort and Binary Search Trees
 

Recently uploaded

The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 

Recently uploaded (20)

The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 

Quicksort with Equal Keys

  • 1. Quicksort with Equal Keys Sebastian Wild wild@cs.uni-kl.de based on joint work with Martin Aumüller, Martin Dietzfelbinger, Conrado Martínez, and Markus Nebel Data Structures and Advanced Models of Computation on Big Data Dagstuhl Seminar 16 101 Sebastian Wild Quicksort with Equal Keys 2016-03-07 1 / 12
  • 2. Motivation Practical Dimension: solve togetherness problem e.g. SQL’s GROUP BY clause preprocessing to remove dups Theoretical Dimension: many equals lower entropy We should be able to sort faster! Academic Dimension: Open Problem of Sedgewick & Bentley: Is Quicksort with median-of-k entropy-optimal for k → ∞? Personal Dimension: This is my tenth talk on Quicksort ... Equal Keys on my wishlist since 2012 Why Equal Keys? Sebastian Wild Quicksort with Equal Keys 2016-03-07 2 / 12
  • 3. Motivation Practical Dimension: solve togetherness problem e.g. SQL’s GROUP BY clause preprocessing to remove dups Theoretical Dimension: many equals lower entropy We should be able to sort faster! Academic Dimension: Open Problem of Sedgewick & Bentley: Is Quicksort with median-of-k entropy-optimal for k → ∞? Personal Dimension: This is my tenth talk on Quicksort ... Equal Keys on my wishlist since 2012 Why Equal Keys? Sebastian Wild Quicksort with Equal Keys 2016-03-07 2 / 12
  • 4. Motivation Practical Dimension: solve togetherness problem e.g. SQL’s GROUP BY clause preprocessing to remove dups Theoretical Dimension: many equals lower entropy We should be able to sort faster! Academic Dimension: Open Problem of Sedgewick & Bentley: Is Quicksort with median-of-k entropy-optimal for k → ∞? Personal Dimension: This is my tenth talk on Quicksort ... Equal Keys on my wishlist since 2012 Why Equal Keys? Sebastian Wild Quicksort with Equal Keys 2016-03-07 2 / 12
  • 5. Motivation Practical Dimension: solve togetherness problem e.g. SQL’s GROUP BY clause preprocessing to remove dups Theoretical Dimension: many equals lower entropy We should be able to sort faster! Academic Dimension: Open Problem of Sedgewick & Bentley: Is Quicksort with median-of-k entropy-optimal for k → ∞? Personal Dimension: This is my tenth talk on Quicksort ... Equal Keys on my wishlist since 2012 Why Equal Keys? Sebastian Wild Quicksort with Equal Keys 2016-03-07 2 / 12
  • 6. Motivation Practical Dimension: solve togetherness problem e.g. SQL’s GROUP BY clause preprocessing to remove dups Theoretical Dimension: many equals lower entropy We should be able to sort faster! Academic Dimension: Open Problem of Sedgewick & Bentley: Is Quicksort with median-of-k entropy-optimal for k → ∞? Personal Dimension: This is my tenth talk on Quicksort ... Equal Keys on my wishlist since 2012 Why Equal Keys? Sebastian Wild Quicksort with Equal Keys 2016-03-07 2 / 12
  • 7. Previous Work 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 with Equal Keys 2016-03-07 3 / 12
  • 8. Previous Work 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 general-purpose sorting method suitable for use on computers. The algorithm has a rich history: many modifications have been suggested to improve its perfor- mance, and exact formulas have been derived describing the time and spaceSebastian Wild Quicksort with Equal Keys 2016-03-07 3 / 12
  • 9. Previous Work 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 general-purpose sorting method suitable for use on computers. The algorithm has a rich history: many modifications have been suggested to improve its perfor- mance, and exact formulas have been derived describing the time and space 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 with Equal Keys 2016-03-07 3 / 12
  • 10. Previous Work 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 general-purpose sorting method suitable for use on computers. The algorithm has a rich history: many modifications have been suggested to improve its perfor- mance, and exact formulas have been derived describing the time and space 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 Introduction The expected depth of the number r in the set of binary search trees formed from allSebastian Wild Quicksort with Equal Keys 2016-03-07 3 / 12
  • 11. Previous Work 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 general-purpose sorting method suitable for use on computers. The algorithm has a rich history: many modifications have been suggested to improve its perfor- mance, and exact formulas have been derived describing the time and space 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 Introduction The expected depth of the number r in the set of binary search trees formed from all 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 Communicated by H. Prodinger Sebastian Wild Quicksort with Equal Keys 2016-03-07 3 / 12
  • 12. Previous Work 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 general-purpose sorting method suitable for use on computers. The algorithm has a rich history: many modifications have been suggested to improve its perfor- mance, and exact formulas have been derived describing the time and space 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 Introduction The expected depth of the number r in the set of binary search trees formed from all 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 Communicated by H. Prodinger 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 Random sequences from alphabet {1, . . . , r} are examined where repeated letters are allowed. Binary search trees are formed from these, and the average left-going depth of the first 1 is found. Next, the right-going depth of the first r is examined, and finally a merge (or ‘shuffle’) operator is used to obtain the average depth of an arbitrary node, which canSebastian Wild Quicksort with Equal Keys 2016-03-07 3 / 12
  • 13. Previous Work 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 general-purpose sorting method suitable for use on computers. The algorithm has a rich history: many modifications have been suggested to improve its perfor- mance, and exact formulas have been derived describing the time and space 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 Introduction The expected depth of the number r in the set of binary search trees formed from all 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 Communicated by H. Prodinger 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 Random sequences from alphabet {1, . . . , r} are examined where repeated letters are allowed. Binary search trees are formed from these, and the average left-going depth of the first 1 is found. Next, the right-going depth of the first r is examined, and finally a merge (or ‘shuffle’) operator is used to obtain the average depth of an arbitrary node, which canSebastian Wild Quicksort with Equal Keys 2016-03-07 3 / 12
  • 14. Previous Work 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 general-purpose sorting method suitable for use on computers. The algorithm has a rich history: many modifications have been suggested to improve its perfor- mance, and exact formulas have been derived describing the time and space 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 Introduction The expected depth of the number r in the set of binary search trees formed from all 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 Communicated by H. Prodinger 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 Random sequences from alphabet {1, . . . , r} are examined where repeated letters are allowed. Binary search trees are formed from these, and the average left-going depth of the first 1 is found. Next, the right-going depth of the first r is examined, and finally a merge (or ‘shuffle’) operator is used to obtain the average depth of an arbitrary node, which can All these works only consider basic Quicksort: No sampling to choose pivots. No multi-way partitioning. Sebastian Wild Quicksort with Equal Keys 2016-03-07 3 / 12
  • 15. Input Models Random-Permutation Model no duplicates 1 1, . . . , n, randomly permuted Parameters: n Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
  • 16. Input Models Random-Permutation Model no duplicates 1 1, . . . , n, randomly permuted Parameters: n Random u-ary Word Model 1 random choice from {1, . . . , u}n Parameters: n, u My claim: u-ary words most natural model ... in particular in i.i.d. interpretation! All previous works use combinatorial detour Stochastic point of view provides shortcut! Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
  • 17. Input Models Random-Permutation Model no duplicates 1 1, . . . , n, randomly permuted 2 n elem. i.i.d. uniform in (0, 1) Parameters: n Random u-ary Word Model 1 random choice from {1, . . . , u}n 2 n elem. i.i.d. uniform in {1, . . . , u} Parameters: n, u My claim: u-ary words most natural model ... in particular in i.i.d. interpretation! All previous works use combinatorial detour Stochastic point of view provides shortcut! Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
  • 18. Input Models Random-Permutation Model no duplicates 1 1, . . . , n, randomly permuted 2 n elem. i.i.d. uniform in (0, 1) Parameters: n Random u-ary Word Model 1 random choice from {1, . . . , u}n 2 n elem. i.i.d. uniform in {1, . . . , u} Parameters: n, u cont. disc. My claim: u-ary words most natural model ... in particular in i.i.d. interpretation! All previous works use combinatorial detour Stochastic point of view provides shortcut! Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
  • 19. Input Models Random-Permutation Model no duplicates 1 1, . . . , n, randomly permuted 2 n elem. i.i.d. uniform in (0, 1) Parameters: n Random u-ary Word Model 1 random choice from {1, . . . , u}n 2 n elem. i.i.d. uniform in {1, . . . , u} Parameters: n, u Multiset-Permutation Model randomly permuted multiset xi copies of i, i = 1, . . . , u Parameters: u; x1, . . . , xuset multiset cont. disc. My claim: u-ary words most natural model ... in particular in i.i.d. interpretation! All previous works use combinatorial detour Stochastic point of view provides shortcut! Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
  • 20. Input Models Random-Permutation Model no duplicates 1 1, . . . , n, randomly permuted 2 n elem. i.i.d. uniform in (0, 1) Parameters: n Random u-ary Word Model 1 random choice from {1, . . . , u}n 2 n elem. i.i.d. uniform in {1, . . . , u} Parameters: n, u Multiset-Permutation Model randomly permuted multiset xi copies of i, i = 1, . . . , u Parameters: u; x1, . . . , xuset multiset aver age cont. disc. My claim: u-ary words most natural model ... in particular in i.i.d. interpretation! All previous works use combinatorial detour Stochastic point of view provides shortcut! Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
  • 21. Input Models Random-Permutation Model no duplicates 1 1, . . . , n, randomly permuted 2 n elem. i.i.d. uniform in (0, 1) Parameters: n Random u-ary Word Model 1 random choice from {1, . . . , u}n 2 n elem. i.i.d. uniform in {1, . . . , u} Parameters: n, u Multiset-Permutation Model randomly permuted multiset xi copies of i, i = 1, . . . , u Parameters: u; x1, . . . , xuset multiset aver age cont. disc. hard to analyze My claim: u-ary words most natural model ... in particular in i.i.d. interpretation! All previous works use combinatorial detour Stochastic point of view provides shortcut! Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
  • 22. Input Models Random-Permutation Model no duplicates 1 1, . . . , n, randomly permuted 2 n elem. i.i.d. uniform in (0, 1) Parameters: n Random u-ary Word Model 1 random choice from {1, . . . , u}n 2 n elem. i.i.d. uniform in {1, . . . , u} Parameters: n, u Multiset-Permutation Model randomly permuted multiset xi copies of i, i = 1, . . . , u Parameters: u; x1, . . . , xuset multiset aver age cont. disc. hard to analyze My claim: u-ary words most natural model ... in particular in i.i.d. interpretation! All previous works use combinatorial detour Stochastic point of view provides shortcut! Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
  • 23. Input Models Random-Permutation Model no duplicates 1 1, . . . , n, randomly permuted 2 n elem. i.i.d. uniform in (0, 1) Parameters: n Random u-ary Word Model 1 random choice from {1, . . . , u}n 2 n elem. i.i.d. uniform in {1, . . . , u} Parameters: n, u Multiset-Permutation Model randomly permuted multiset xi copies of i, i = 1, . . . , u Parameters: u; x1, . . . , xuset multiset aver age cont. disc. hard to analyze My claim: u-ary words most natural model ... in particular in i.i.d. interpretation! All previous works use combinatorial detour Stochastic point of view provides shortcut! Sebastian Wild Quicksort with Equal Keys 2016-03-07 4 / 12
  • 24. Setup Assumptions: 1 Input: U1, . . . , Un, i.i.d. uniform in {1, . . . , u}. 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems again random u-ary words, (with smaller u and n) 3 Cost: # ternary comparisons (extensions possible) Generalized Quicksort: s-way partitioning: divide into s segments pivot sampling: parameter t = (t1, . . . , ts) median-of-(2t + 1) t = (t, t) asymmetric sampling allowed Example: s = 3 and t = (1, 2, 3) P1 P2 t1 t2 t3 2nd and 5th from sample of 8. Sebastian Wild Quicksort with Equal Keys 2016-03-07 5 / 12
  • 25. Setup Assumptions: 1 Input: U1, . . . , Un, i.i.d. uniform in {1, . . . , u}. 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems again random u-ary words, (with smaller u and n) 3 Cost: # ternary comparisons (extensions possible) Generalized Quicksort: s-way partitioning: divide into s segments pivot sampling: parameter t = (t1, . . . , ts) median-of-(2t + 1) t = (t, t) asymmetric sampling allowed Example: s = 3 and t = (1, 2, 3) P1 P2 t1 t2 t3 2nd and 5th from sample of 8. Sebastian Wild Quicksort with Equal Keys 2016-03-07 5 / 12
  • 26. Setup Assumptions: 1 Input: U1, . . . , Un, i.i.d. uniform in {1, . . . , u}. 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems again random u-ary words, (with smaller u and n) 3 Cost: # ternary comparisons (extensions possible) Generalized Quicksort: s-way partitioning: divide into s segments pivot sampling: parameter t = (t1, . . . , ts) median-of-(2t + 1) t = (t, t) asymmetric sampling allowed Example: s = 3 and t = (1, 2, 3) P1 P2 t1 t2 t3 2nd and 5th from sample of 8. Sebastian Wild Quicksort with Equal Keys 2016-03-07 5 / 12
  • 27. Setup Assumptions: 1 Input: U1, . . . , Un, i.i.d. uniform in {1, . . . , u}. 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems again random u-ary words, (with smaller u and n) 3 Cost: # ternary comparisons (extensions possible) Generalized Quicksort: s-way partitioning: divide into s segments pivot sampling: parameter t = (t1, . . . , ts) median-of-(2t + 1) t = (t, t) asymmetric sampling allowed Example: s = 3 and t = (1, 2, 3) P1 P2 t1 t2 t3 2nd and 5th from sample of 8. Sebastian Wild Quicksort with Equal Keys 2016-03-07 5 / 12
  • 28. Setup Assumptions: 1 Input: U1, . . . , Un, i.i.d. uniform in {1, . . . , u}. 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems again random u-ary words, (with smaller u and n) 3 Cost: # ternary comparisons (extensions possible) Generalized Quicksort: s-way partitioning: divide into s segments pivot sampling: parameter t = (t1, . . . , ts) median-of-(2t + 1) t = (t, t) asymmetric sampling allowed Example: s = 3 and t = (1, 2, 3) P1 P2 t1 t2 t3 2nd and 5th from sample of 8. Sebastian Wild Quicksort with Equal Keys 2016-03-07 5 / 12
  • 29. Setup Assumptions: 1 Input: U1, . . . , Un, i.i.d. uniform in {1, . . . , u}. 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems again random u-ary words, (with smaller u and n) 3 Cost: # ternary comparisons (extensions possible) Generalized Quicksort: s-way partitioning: divide into s segments pivot sampling: parameter t = (t1, . . . , ts) median-of-(2t + 1) t = (t, t) asymmetric sampling allowed Example: s = 3 and t = (1, 2, 3) P1 P2 t1 t2 t3 2nd and 5th from sample of 8. Sebastian Wild Quicksort with Equal Keys 2016-03-07 5 / 12
  • 30. Setup Assumptions: 1 Input: U1, . . . , Un, i.i.d. uniform in {1, . . . , u}. 2 fat-pivot partitioning < P P P P > P recursive call recursive callall duplicates of pivots removed subproblems again random u-ary words, (with smaller u and n) 3 Cost: # ternary comparisons (extensions possible) Generalized Quicksort: s-way partitioning: divide into s segments pivot sampling: parameter t = (t1, . . . , ts) median-of-(2t + 1) t = (t, t) asymmetric sampling allowed Example: s = 3 and t = (1, 2, 3) P1 P2 t1 t2 t3 2nd and 5th from sample of 8. Sebastian Wild Quicksort with Equal Keys 2016-03-07 5 / 12
  • 31. 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 with Equal Keys 2016-03-07 6 / 12
  • 32. 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 with Equal Keys 2016-03-07 6 / 12
  • 33. 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 with Equal Keys 2016-03-07 6 / 12
  • 34. 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 with Equal Keys 2016-03-07 6 / 12
  • 35. 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 with Equal Keys 2016-03-07 6 / 12
  • 36. 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 with Equal Keys 2016-03-07 6 / 12
  • 37. 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 with Equal Keys 2016-03-07 6 / 12
  • 38. 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 with Equal Keys 2016-03-07 6 / 12
  • 39. 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 with Equal Keys 2016-03-07 6 / 12
  • 40. 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 with Equal Keys 2016-03-07 6 / 12
  • 41. 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 with Equal Keys 2016-03-07 6 / 12
  • 42. 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 with Equal Keys 2016-03-07 6 / 12
  • 43. 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 with Equal Keys 2016-03-07 6 / 12
  • 44. 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 with Equal Keys 2016-03-07 6 / 12
  • 45. 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 with Equal Keys 2016-03-07 6 / 12
  • 46. 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 with Equal Keys 2016-03-07 6 / 12
  • 47. 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 with Equal Keys 2016-03-07 6 / 12
  • 48. 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 with Equal Keys 2016-03-07 6 / 12
  • 49. 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 with Equal Keys 2016-03-07 6 / 12
  • 50. 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 with Equal Keys 2016-03-07 6 / 12
  • 51. 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 with Equal Keys 2016-03-07 6 / 12
  • 52. 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 with Equal Keys 2016-03-07 6 / 12
  • 53. 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 with Equal Keys 2016-03-07 6 / 12
  • 54. 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 with Equal Keys 2016-03-07 6 / 12
  • 55. 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 with Equal Keys 2016-03-07 6 / 12
  • 56. 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 with Equal Keys 2016-03-07 6 / 12
  • 57. 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 with Equal Keys 2016-03-07 6 / 12
  • 58. 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 with Equal Keys 2016-03-07 6 / 12
  • 59. 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 with Equal Keys 2016-03-07 6 / 12
  • 60. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
  • 61. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 4 2 1 3 3 5 4 4 3 5 2 Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
  • 62. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 4 2 1 3 3 5 4 4 3 5 2 Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
  • 63. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 4 2 1 3 3 5 4 4 3 5 2 Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
  • 64. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
  • 65. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 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 with Equal Keys 2016-03-07 7 / 12
  • 66. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
  • 67. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 4 2 1 3 3 5 4 4 3 5 2 2 1 2 4 5 4 4 533 3 Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
  • 68. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 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 with Equal Keys 2016-03-07 7 / 12
  • 69. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 70. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 71. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 72. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 73. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 74. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 75. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 76. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 77. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 78. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 79. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 80. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 81. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 82. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 83. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 84. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 85. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 86. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 87. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 with Equal Keys 2016-03-07 7 / 12
  • 88. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 Analyze search trees instead of Quicksort. Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
  • 89. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 Analyze search trees instead of Quicksort. Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
  • 90. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 Analyze search trees instead of Quicksort. Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
  • 91. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 Analyze search trees instead of Quicksort. Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
  • 92. Fringe-Balanced Trees Fringe-Balanced Search Trees: Leaves have buffer for elements, to emulate pivot sampling Median-of-5 Quicksort t = (2, 2) 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 Analyze search trees instead of Quicksort. Sebastian Wild Quicksort with Equal Keys 2016-03-07 7 / 12
  • 93. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 94. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 95. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 96. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 97. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 98. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 99. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 100. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 101. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 102. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 103. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 104. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 105. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 106. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 107. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 108. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 109. 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 Observation: T becomes stationary after 1 insert of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 110. 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 (w = 1) Observation: T becomes stationary after w inserts of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 111. 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 (w = 1) Observation: T becomes stationary after w inserts of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 112. 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 (w = 1) tree-growing part T Observation: T becomes stationary after w inserts of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 113. 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 (w = 1) tree-growing part T searching part XS Observation: T becomes stationary after w inserts of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 114. 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 (w = 1) tree-growing part T searching part XS Observation: T becomes stationary after w inserts of each value! with leaf-buffer size w 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 with Equal Keys 2016-03-07 8 / 12
  • 115. Bounding Tree-Growing Parts We ignore tree-growing in analysis have to make that part short. Allow first nT = n2/3 elements to build T. 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 XS nT Input is degenerate if a value occurs < w times in first nT elements. T not complete after nT inserts ... Have to make this happen rarely. By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4 ) building T costs nT · u = O(n1−ε ) Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε ) αu = expected search cost in random T error term: covers tree-growing, sorting samples, degenerate inputs Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
  • 116. Bounding Tree-Growing Parts We ignore tree-growing in analysis have to make that part short. Allow first nT = n2/3 elements to build T. 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 XS nT Input is degenerate if a value occurs < w times in first nT elements. T not complete after nT inserts ... Have to make this happen rarely. By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4 ) building T costs nT · u = O(n1−ε ) Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε ) αu = expected search cost in random T error term: covers tree-growing, sorting samples, degenerate inputs Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
  • 117. Bounding Tree-Growing Parts We ignore tree-growing in analysis have to make that part short. Allow first nT = n2/3 elements to build T. 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 XS nT Input is degenerate if a value occurs < w times in first nT elements. T not complete after nT inserts ... Have to make this happen rarely. By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4 ) building T costs nT · u = O(n1−ε ) Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε ) αu = expected search cost in random T error term: covers tree-growing, sorting samples, degenerate inputs Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
  • 118. Bounding Tree-Growing Parts We ignore tree-growing in analysis have to make that part short. Allow first nT = n2/3 elements to build T. 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 XS nT Input is degenerate if a value occurs < w times in first nT elements. T not complete after nT inserts ... Have to make this happen rarely. By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4 ) building T costs nT · u = O(n1−ε ) Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε ) αu = expected search cost in random T error term: covers tree-growing, sorting samples, degenerate inputs Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
  • 119. Bounding Tree-Growing Parts We ignore tree-growing in analysis have to make that part short. Allow first nT = n2/3 elements to build T. 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 XS nT Input is degenerate if a value occurs < w times in first nT elements. T not complete after nT inserts ... Have to make this happen rarely. By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4 ) building T costs nT · u = O(n1−ε ) Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε ) αu = expected search cost in random T error term: covers tree-growing, sorting samples, degenerate inputs Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
  • 120. Bounding Tree-Growing Parts We ignore tree-growing in analysis have to make that part short. Allow first nT = n2/3 elements to build T. 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 XS nT Input is degenerate if a value occurs < w times in first nT elements. T not complete after nT inserts ... Have to make this happen rarely. By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4 ) building T costs nT · u = O(n1−ε ) Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε ) αu = expected search cost in random T error term: covers tree-growing, sorting samples, degenerate inputs Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
  • 121. Bounding Tree-Growing Parts We ignore tree-growing in analysis have to make that part short. Allow first nT = n2/3 elements to build T. 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 XS nT Input is degenerate if a value occurs < w times in first nT elements. T not complete after nT inserts ... Have to make this happen rarely. By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4 ) building T costs nT · u = O(n1−ε ) Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε ) αu = expected search cost in random T error term: covers tree-growing, sorting samples, degenerate inputs Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
  • 122. Bounding Tree-Growing Parts We ignore tree-growing in analysis have to make that part short. Allow first nT = n2/3 elements to build T. 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 XS nT Input is degenerate if a value occurs < w times in first nT elements. T not complete after nT inserts ... Have to make this happen rarely. By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4 ) building T costs nT · u = O(n1−ε ) Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε ) αu = expected search cost in random T error term: covers tree-growing, sorting samples, degenerate inputs Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
  • 123. Bounding Tree-Growing Parts We ignore tree-growing in analysis have to make that part short. Allow first nT = n2/3 elements to build T. 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 XS nT Input is degenerate if a value occurs < w times in first nT elements. T not complete after nT inserts ... Have to make this happen rarely. By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4 ) building T costs nT · u = O(n1−ε ) Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε ) αu = expected search cost in random T error term: covers tree-growing, sorting samples, degenerate inputs Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
  • 124. Bounding Tree-Growing Parts We ignore tree-growing in analysis have to make that part short. Allow first nT = n2/3 elements to build T. 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 XS nT Input is degenerate if a value occurs < w times in first nT elements. T not complete after nT inserts ... Have to make this happen rarely. By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4 ) building T costs nT · u = O(n1−ε ) Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε ) αu = expected search cost in random T error term: covers tree-growing, sorting samples, degenerate inputs Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
  • 125. Bounding Tree-Growing Parts We ignore tree-growing in analysis have to make that part short. Allow first nT = n2/3 elements to build T. 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 XS nT Input is degenerate if a value occurs < w times in first nT elements. T not complete after nT inserts ... Have to make this happen rarely. By Chernoff bounds, input is non-degenerate w.h.p. if u = O(n1/4 ) building T costs nT · u = O(n1−ε ) Expected Quicksort cost E[Cn,u] = αu · n ± O(n1−ε ) αu = expected search cost in random T error term: covers tree-growing, sorting samples, degenerate inputs Sebastian Wild Quicksort with Equal Keys 2016-03-07 9 / 12
  • 126. Search Costs Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation. αu = 1 u u v=1 cost of searching v in T (u · αu = path length of T) 1 Easy case: t = (0, 0) ordinary BST, w = 1 no duplicates in tree T is BST under random permutation model Allen & Munro 1978: Self-Organizing Binary Search Trees 2 General t = (t1, . . . , ts): duplicates inside leaves (during construction) 3 3 for s 3: duplicates in same internal node possible = random permutation But: can set up a (messy) recurrence for αu asymptotic solution by Continuous Master Theorem Roura 2001: Improved Master Theorems for Divide-and-Conquer Recurrences Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
  • 127. Search Costs Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation. αu = 1 u u v=1 cost of searching v in T (u · αu = path length of T) 1 Easy case: t = (0, 0) ordinary BST, w = 1 no duplicates in tree T is BST under random permutation model Allen & Munro 1978: Self-Organizing Binary Search Trees 2 General t = (t1, . . . , ts): duplicates inside leaves (during construction) 3 3 for s 3: duplicates in same internal node possible = random permutation But: can set up a (messy) recurrence for αu asymptotic solution by Continuous Master Theorem Roura 2001: Improved Master Theorems for Divide-and-Conquer Recurrences Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
  • 128. Search Costs Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation. αu = 1 u u v=1 cost of searching v in T (u · αu = path length of T) 1 Easy case: t = (0, 0) ordinary BST, w = 1 no duplicates in tree T is BST under random permutation model Allen & Munro 1978: Self-Organizing Binary Search Trees 2 General t = (t1, . . . , ts): duplicates inside leaves (during construction) 3 3 for s 3: duplicates in same internal node possible = random permutation But: can set up a (messy) recurrence for αu asymptotic solution by Continuous Master Theorem Roura 2001: Improved Master Theorems for Divide-and-Conquer Recurrences Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
  • 129. Search Costs Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation. αu = 1 u u v=1 cost of searching v in T (u · αu = path length of T) 1 Easy case: t = (0, 0) ordinary BST, w = 1 no duplicates in tree T is BST under random permutation model Allen & Munro 1978: Self-Organizing Binary Search Trees 2 General t = (t1, . . . , ts): duplicates inside leaves (during construction) 3 3 for s 3: duplicates in same internal node possible = random permutation But: can set up a (messy) recurrence for αu asymptotic solution by Continuous Master Theorem Roura 2001: Improved Master Theorems for Divide-and-Conquer Recurrences Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
  • 130. Search Costs Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation. αu = 1 u u v=1 cost of searching v in T (u · αu = path length of T) 1 Easy case: t = (0, 0) ordinary BST, w = 1 no duplicates in tree T is BST under random permutation model Allen & Munro 1978: Self-Organizing Binary Search Trees 2 General t = (t1, . . . , ts): duplicates inside leaves (during construction) 3 3 for s 3: duplicates in same internal node possible = random permutation But: can set up a (messy) recurrence for αu asymptotic solution by Continuous Master Theorem Roura 2001: Improved Master Theorems for Divide-and-Conquer Recurrences Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
  • 131. Search Costs Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation. αu = 1 u u v=1 cost of searching v in T (u · αu = path length of T) 1 Easy case: t = (0, 0) ordinary BST, w = 1 no duplicates in tree T is BST under random permutation model Allen & Munro 1978: Self-Organizing Binary Search Trees αu = 2 1 + 1 u Hu − 3 = 2 ln(u) ± O(1) 2 General t = (t1, . . . , ts): duplicates inside leaves (during construction) 3 3 for s 3: duplicates in same internal node possible = random permutation But: can set up a (messy) recurrence for αu asymptotic solution by Continuous Master Theorem Roura 2001: Improved Master Theorems for Divide-and-Conquer Recurrences Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
  • 132. Search Costs Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation. αu = 1 u u v=1 cost of searching v in T (u · αu = path length of T) 1 Easy case: t = (0, 0) ordinary BST, w = 1 no duplicates in tree T is BST under random permutation model Allen & Munro 1978: Self-Organizing Binary Search Trees αu = 2 1 + 1 u Hu − 3 = 2 ln(u) ± O(1) 2 General t = (t1, . . . , ts): duplicates inside leaves (during construction) 3 3 for s 3: duplicates in same internal node possible = random permutation But: can set up a (messy) recurrence for αu asymptotic solution by Continuous Master Theorem Roura 2001: Improved Master Theorems for Divide-and-Conquer Recurrences Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
  • 133. Search Costs Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation. αu = 1 u u v=1 cost of searching v in T (u · αu = path length of T) 1 Easy case: t = (0, 0) ordinary BST, w = 1 no duplicates in tree T is BST under random permutation model Allen & Munro 1978: Self-Organizing Binary Search Trees αu = 2 1 + 1 u Hu − 3 = 2 ln(u) ± O(1) 2 General t = (t1, . . . , ts): duplicates inside leaves (during construction) 3 3 for s 3: duplicates in same internal node possible = random permutation But: can set up a (messy) recurrence for αu asymptotic solution by Continuous Master Theorem Roura 2001: Improved Master Theorems for Divide-and-Conquer Recurrences Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
  • 134. Search Costs Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation. αu = 1 u u v=1 cost of searching v in T (u · αu = path length of T) 1 Easy case: t = (0, 0) ordinary BST, w = 1 no duplicates in tree T is BST under random permutation model Allen & Munro 1978: Self-Organizing Binary Search Trees αu = 2 1 + 1 u Hu − 3 = 2 ln(u) ± O(1) 2 General t = (t1, . . . , ts): duplicates inside leaves (during construction) 3 3 1 2 4 for s 3: duplicates in same internal node possible = random permutation But: can set up a (messy) recurrence for αu asymptotic solution by Continuous Master Theorem Roura 2001: Improved Master Theorems for Divide-and-Conquer Recurrences Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
  • 135. Search Costs Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation. αu = 1 u u v=1 cost of searching v in T (u · αu = path length of T) 1 Easy case: t = (0, 0) ordinary BST, w = 1 no duplicates in tree T is BST under random permutation model Allen & Munro 1978: Self-Organizing Binary Search Trees αu = 2 1 + 1 u Hu − 3 = 2 ln(u) ± O(1) 2 General t = (t1, . . . , ts): duplicates inside leaves (during construction) 3 3 1 2 4 for s 3: duplicates in same internal node possible = random permutation But: can set up a (messy) recurrence for αu asymptotic solution by Continuous Master Theorem Roura 2001: Improved Master Theorems for Divide-and-Conquer Recurrences Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
  • 136. Search Costs Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation. αu = 1 u u v=1 cost of searching v in T (u · αu = path length of T) 1 Easy case: t = (0, 0) ordinary BST, w = 1 no duplicates in tree T is BST under random permutation model Allen & Munro 1978: Self-Organizing Binary Search Trees αu = 2 1 + 1 u Hu − 3 = 2 ln(u) ± O(1) 2 General t = (t1, . . . , ts): duplicates inside leaves (during construction) 3 3 1 2 4 for s 3: duplicates in same internal node possible = random permutation But: can set up a (messy) recurrence for αu asymptotic solution by Continuous Master Theorem Roura 2001: Improved Master Theorems for Divide-and-Conquer Recurrences Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
  • 137. Search Costs Recall: T built from inserting i.i.d. uniform {1, . . . , u}, until saturation. αu = 1 u u v=1 cost of searching v in T (u · αu = path length of T) 1 Easy case: t = (0, 0) ordinary BST, w = 1 no duplicates in tree T is BST under random permutation model Allen & Munro 1978: Self-Organizing Binary Search Trees αu = 2 1 + 1 u Hu − 3 = 2 ln(u) ± O(1) 2 General t = (t1, . . . , ts): duplicates inside leaves (during construction) 3 3 1 2 4 for s 3: duplicates in same internal node possible = random permutation But: can set up a (messy) recurrence for αu asymptotic solution by Continuous Master Theorem Roura 2001: Improved Master Theorems for Divide-and-Conquer Recurrences Sebastian Wild Quicksort with Equal Keys 2016-03-07 10 / 12
  • 138. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 139. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 140. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 141. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 142. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 143. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 1 2 3 4 3 1 2 4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 144. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 1 2 3 4 3 1 2 4 ¯a = 2.4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 145. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 1 2 3 4 3 1 2 4 ¯a = 2.4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 146. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 1 2 3 4 3 1 2 4 ¯a = 2.4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 147. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 1 2 3 4 3 1 2 4 ¯a = 2.4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 148. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 1 2 3 4 3 1 2 4 ¯a = 2.4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 149. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 1 2 3 4 3 1 2 4 ¯a = 2.4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 150. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 1 2 3 4 3 1 2 4 ¯a = 2.4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 151. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 1 2 3 4 3 1 2 4 ¯a = 2.4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Results deceptively similar! (derivation isn’t) Same speedup from sampling and multi-way partitioning. Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 152. Result Search costs in T: αu = ¯a H ln(u) ± O(1) u → ∞ H = s r=1 tr + 1 k + 1 Hk+1 − Htr+1 k = sample size ¯a = avg. search costs inside node 1 2 3 4 1 2 3 4 3 1 2 4 ¯a = 2.4 (¯a = 1 for binary trees) Quicksort costs: E[Cn,u] = αu · n ± O(n1−ε ) u = O(n1/4) Time to put the pieces together! Quicksort Costs u-ary words: E[Cn,u] = ¯a H n ln(u) ± O(n) u = ω(1), u = O(n1/4 ) Permutations: E[Cn] = ¯a H n ln(n) ± O(n) Results deceptively similar! (derivation isn’t) Same speedup from sampling and multi-way partitioning. Sebastian Wild Quicksort with Equal Keys 2016-03-07 11 / 12
  • 153. Conclusion Findings First analysis of generalized Quicksort (sampling & multi-way) on equal keys. Limitations: restricted range for universe size: u = ω(1) and u = O(n1/3−ε ) currently only stateless cost measures Partial Answer to conjecture of Sedgewick & Bentley: Median-of-k Quicksort approaches lower bound for k → ∞ ... for uniform distribution. Finally cleared the item from my to-do list Future Work other discrete distributions expected-profile model better asymptotic approximation for αu Sebastian Wild Quicksort with Equal Keys 2016-03-07 12 / 12
  • 154. Conclusion Findings First analysis of generalized Quicksort (sampling & multi-way) on equal keys. Limitations: restricted range for universe size: u = ω(1) and u = O(n1/3−ε ) currently only stateless cost measures Partial Answer to conjecture of Sedgewick & Bentley: Median-of-k Quicksort approaches lower bound for k → ∞ ... for uniform distribution. Finally cleared the item from my to-do list Future Work other discrete distributions expected-profile model better asymptotic approximation for αu Sebastian Wild Quicksort with Equal Keys 2016-03-07 12 / 12
  • 155. Conclusion Findings First analysis of generalized Quicksort (sampling & multi-way) on equal keys. Limitations: restricted range for universe size: u = ω(1) and u = O(n1/3−ε ) currently only stateless cost measures Partial Answer to conjecture of Sedgewick & Bentley: Median-of-k Quicksort approaches lower bound for k → ∞ ... for uniform distribution. Finally cleared the item from my to-do list Future Work other discrete distributions expected-profile model better asymptotic approximation for αu Sebastian Wild Quicksort with Equal Keys 2016-03-07 12 / 12