|
ABSTRACT
We introduce the notion of discrimination as a generalization of both sorting and partitioning and show that worst-case linear-time discrimination functions (discriminators) can be defined generically, by (co-)induction on an expressive language of order denotations. The generic definition yields discriminators that generalize both distributive sorting and multiset discrimination. The generic discriminator can be coded compactly using list comprehensions, with order denotations specified using Generalized Algebraic Data Types (GADTs). A GADT-free combinator formulation of discriminators is also given. We give some examples of the uses of discriminators, including a new most-significant-digit lexicographic sorting algorithm. Discriminators generalize binary comparison functions: They operate on n arguments at a time, but do not expose more information than the underlying equivalence, respectively ordering relation on the arguments. We argue that primitive types with equality (such as references in ML) and ordered types (such as the machine integer type), should expose their equality, respectively standard ordering relation, as discriminators: Having only a binary equality test on a type requires Θ(n2) time to find all the occurrences of an element in a list of length n, for each element in the list, even if the equality test takes only constant time. A discriminator accomplishes this in linear time. Likewise, having only a (constant-time) comparison function requires Θ(n log n) time to sort a list of n elements. A discriminator can do this in linear time.
REFERENCES
Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.
| |
1
|
|
| |
2
|
Thomas Ambus. Multiset discrimination for internal and external data management. Master's thesis, DIKU, University of Copenhagen, July 2004. http://plan-x.org/projects/msd/msd.pdf.
|
| |
3
|
|
 |
4
|
|
| |
5
|
|
| |
6
|
K. E. Batcher. Sorting networks and their applications. In Proc. AFIPS Spring Joint Computer Conference, volume 32, pages 307--314, 1968.
|
 |
7
|
|
 |
8
|
Jiazhen Cai , Robert A. Paige, Look ma, no hashing, and no arrays neither, Proceedings of the 18th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, p.143-154, January 21-23, 1991, Orlando, Florida, United States
[doi> 10.1145/99583.99605]
|
| |
9
|
|
| |
10
|
Gianni Franceschini, S. Muthukrishnan, and Mihai Patrascu. Radix sorting with no extra space. In Proc. European Symposium on Algorithms (ESA), volume 4698 of Lecture Notes in Computer Science (LNCS), pages 194--205. Springer, 2007. doi: 10.1007/978-3-540-75520-3.
|
| |
11
|
|
| |
12
|
Glasgow Haskell. The Glasgow Haskell Compiler. http://www.haskell.org/ghc/, 2005.
|
| |
13
|
|
| |
14
|
Fritz Henglein. Multiset discrimination. Unpublished manuscript. See http://plan-x.org/msd/multiset-discrimination.pdf, September 2003.
|
| |
15
|
Fritz Henglein. A language for total preorders. Unfinished manuscript, March 2008.
|
 |
16
|
|
| |
17
|
|
 |
18
|
|
| |
19
|
|
| |
20
|
Sian Jha, Jens Palsberg, Tian Zhao, and Fritz Henglein. Efficient type matching. In Olivier Danvy, Fritz Henglein, Harry Mairson, and Alberto Pettorossi, editors, Automatic Program Development-A Tribute to Robert Paige. Springer, 2008. ISBN 978-1-4020-6584-2.
|
| |
21
|
|
| |
22
|
|
| |
23
|
R. Paige. Optimal translation of user input in dynamically typed languages. Draft, July 1991.
|
| |
24
|
Robert Paige. Efficient translation of external input in a dynamically typed language. In Proc. 13th World Computer Congress. Elsevier, February 1994.
|
| |
25
|
|
 |
26
|
|
 |
27
|
|
| |
28
|
|
| |
29
|
J. W. J. Williams. Algorithm 232 - heapsort. Communications of the ACM, 7(6):347--348, 1964.
|
 |
30
|
Yoav Zibin , Joseph (Yossi) Gil , Jeffrey Considine, Efficient algorithms for isomorphisms of simple types, Proceedings of the 30th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, p.160-171, January 15-17, 2003, New Orleans, Louisiana, USA
|
INDEX TERMS
Primary Classification:
F.
Theory of Computation
F.2
ANALYSIS OF ALGORITHMS AND PROBLEM COMPLEXITY
F.2.2
Nonnumerical Algorithms and Problems
Additional Classification:
D.
Software
D.1
PROGRAMMING TECHNIQUES
D.1.1
Applicative (Functional) Programming
General Terms:
Algorithms,
Languages,
Theory
Keywords:
discrimination,
discriminator,
equivalence,
functional,
generic,
multiset discrimination,
order,
partitioning,
sorting,
total preorder
|