SlideShare une entreprise Scribd logo
1  sur  236
Télécharger pour lire hors ligne
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

Contenu connexe

Similaire à Quicksort with Equal Keys

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 incrementalAlexander 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 incrementalAlexander Decker
 
Constructing Operating Systems and E-Commerce
Constructing Operating Systems and E-CommerceConstructing Operating Systems and E-Commerce
Constructing Operating Systems and E-CommerceIJARIIT
 
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_SFStartupDayAmazon 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 AlgorithmsSara 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 discoveryAnubhav Jain
 
A Case for E-Business
A Case for E-BusinessA Case for E-Business
A Case for E-Businessijsrd.com
 
ast nearest neighbor search with keywords
ast nearest neighbor search with keywordsast nearest neighbor search with keywords
ast nearest neighbor search with keywordsswathi78
 
IA3_presentation.pptx
IA3_presentation.pptxIA3_presentation.pptx
IA3_presentation.pptxKtonNguyn2
 
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 miningIRJET 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 2016ijcsbi
 
Introduction and Applications of Discrete Mathematics
Introduction and Applications of Discrete MathematicsIntroduction and Applications of Discrete Mathematics
Introduction and Applications of Discrete Mathematicsblaircomp2003
 
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 HadoopBRNSSPublicationHubI
 
Review Over Sequential Rule Mining
Review Over Sequential Rule MiningReview Over Sequential Rule Mining
Review Over Sequential Rule Miningijsrd.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
 

Similaire à 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)
 

Plus de 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 ProblemsSebastian 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 SpaceSebastian 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 selectionSebastian 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 samplingSebastian 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 keysSebastian Wild
 
Quicksort and Binary Search Trees
Quicksort and Binary Search TreesQuicksort and Binary Search Trees
Quicksort and Binary Search TreesSebastian Wild
 

Plus de 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
 

Dernier

Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 

Dernier (20)

Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

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