Data Structures. Sorting. Haim Kaplan & Uri Zwick December 2013

Similar documents
II (Sorting and) Order Statistics

Lower Bound on Comparison-based Sorting

Lecture 9: Sorting Algorithms

Module 3: Sorting and Randomized Algorithms

Module 3: Sorting and Randomized Algorithms. Selection vs. Sorting. Crucial Subroutines. CS Data Structures and Data Management

Module 3: Sorting and Randomized Algorithms

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Sorting lower bound and Linear-time sorting Date: 9/19/17

Sorting is a problem for which we can prove a non-trivial lower bound.

How many leaves on the decision tree? There are n! leaves, because every permutation appears at least once.

Question 7.11 Show how heapsort processes the input:

CSE 3101: Introduction to the Design and Analysis of Algorithms. Office hours: Wed 4-6 pm (CSEB 3043), or by appointment.

CPSC 311 Lecture Notes. Sorting and Order Statistics (Chapters 6-9)

COMP Data Structures

Sorting. Sorting. Stable Sorting. In-place Sort. Bubble Sort. Bubble Sort. Selection (Tournament) Heapsort (Smoothsort) Mergesort Quicksort Bogosort

Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Merge Sort & Quick Sort

How fast can we sort? Sorting. Decision-tree example. Decision-tree example. CS 3343 Fall by Charles E. Leiserson; small changes by Carola

Chapter 8 Sorting in Linear Time

Data Structures and Algorithms. Roberto Sebastiani

Comparison Based Sorting Algorithms. Algorithms and Data Structures: Lower Bounds for Sorting. Comparison Based Sorting Algorithms

Sorting: Given a list A with n elements possessing a total order, return a list with the same elements in non-decreasing order.

EECS 2011M: Fundamentals of Data Structures

Lecture 5: Sorting Part A

Data Structures and Algorithms Chapter 4

Algorithms and Data Structures: Lower Bounds for Sorting. ADS: lect 7 slide 1

CS61B Lectures # Purposes of Sorting. Some Definitions. Classifications. Sorting supports searching Binary search standard example

Quicksort (CLRS 7) We saw the divide-and-conquer technique at work resulting in Mergesort. Mergesort summary:

CS2223: Algorithms Sorting Algorithms, Heap Sort, Linear-time sort, Median and Order Statistics

Bin Sort. Sorting integers in Range [1,...,n] Add all elements to table and then

Problem. Input: An array A = (A[1],..., A[n]) with length n. Output: a permutation A of A, that is sorted: A [i] A [j] for all. 1 i j n.

Sorting and Selection

Randomized Algorithms, Quicksort and Randomized Selection

Data Structures and Algorithms

Sorting. Dr. Baldassano Yu s Elite Education

The complexity of Sorting and sorting in linear-time. Median and Order Statistics. Chapter 8 and Chapter 9

Sorting Algorithms. For special input, O(n) sorting is possible. Between O(n 2 ) and O(nlogn) E.g., input integer between O(n) and O(n)

7. Sorting I. 7.1 Simple Sorting. Problem. Algorithm: IsSorted(A) 1 i j n. Simple Sorting

Jana Kosecka. Linear Time Sorting, Median, Order Statistics. Many slides here are based on E. Demaine, D. Luebke slides

DIVIDE AND CONQUER ALGORITHMS ANALYSIS WITH RECURRENCE EQUATIONS

IS 709/809: Computational Methods in IS Research. Algorithm Analysis (Sorting)

O(n): printing a list of n items to the screen, looking at each item once.

Searching, Sorting. part 1

Divide and Conquer Sorting Algorithms and Noncomparison-based

Comparison Sorts. Chapter 9.4, 12.1, 12.2

Sorting. Bubble Sort. Pseudo Code for Bubble Sorting: Sorting is ordering a list of elements.

CISC 621 Algorithms, Midterm exam March 24, 2016

Lower bound for comparison-based sorting

Data Structures and Algorithms Week 4

SAMPLE OF THE STUDY MATERIAL PART OF CHAPTER 6. Sorting Algorithms

Chapter 8 Sort in Linear Time

1. Covered basics of a simple design technique (Divideand-conquer) 2. Next, more sorting algorithms.

COT 6405 Introduction to Theory of Algorithms

Data Structures and Algorithms 2018

Sorting. Riley Porter. CSE373: Data Structures & Algorithms 1

SORTING AND SELECTION

Lecture 23: Priority Queues, Part 2 10:00 AM, Mar 19, 2018

The divide and conquer strategy has three basic parts. For a given problem of size n,

Sorting Shabsi Walfish NYU - Fundamental Algorithms Summer 2006

Introduction to Algorithms and Data Structures. Lecture 12: Sorting (3) Quick sort, complexity of sort algorithms, and counting sort

CSE373: Data Structure & Algorithms Lecture 21: More Comparison Sorting. Aaron Bauer Winter 2014

Data Structures and Algorithms

CS240 Fall Mike Lam, Professor. Quick Sort

Lecture 3. Recurrences / Heapsort

CSE 143. Two important problems. Searching and Sorting. Review: Linear Search. Review: Binary Search. Example. How Efficient Is Linear Search?

Sorting. Popular algorithms: Many algorithms for sorting in parallel also exist.

Total Points: 60. Duration: 1hr

Sorting Algorithms. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

having any value between and. For array element, the plot will have a dot at the intersection of and, subject to scaling constraints.

Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms

DIVIDE & CONQUER. Problem of size n. Solution to sub problem 1

Shell s sort. CS61B Lecture #25. Sorting by Selection: Heapsort. Example of Shell s Sort

Algorithms and Data Structures (INF1) Lecture 7/15 Hua Lu

Next. 1. Covered basics of a simple design technique (Divideand-conquer) 2. Next, more sorting algorithms.

Introduction. e.g., the item could be an entire block of information about a student, while the search key might be only the student's name

8 SortinginLinearTime

CSC 505, Spring 2005 Week 6 Lectures page 1 of 9

4. Sorting and Order-Statistics

UNIT-2 DIVIDE & CONQUER

CS 303 Design and Analysis of Algorithms

Sorting. There exist sorting algorithms which have shown to be more efficient in practice.

11/8/2016. Chapter 7 Sorting. Introduction. Introduction. Sorting Algorithms. Sorting. Sorting

CS 137 Part 8. Merge Sort, Quick Sort, Binary Search. November 20th, 2017

Design and Analysis of Algorithms

e-pg PATHSHALA- Computer Science Design and Analysis of Algorithms Module 10

Divide and Conquer CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang

Pseudo code of algorithms are to be read by.

1 (15 points) LexicoSort

SORTING, SETS, AND SELECTION

8. Sorting II. 8.1 Heapsort. Heapsort. [Max-]Heap 6. Heapsort, Quicksort, Mergesort. Binary tree with the following properties Wurzel

Unit 6 Chapter 15 EXAMPLES OF COMPLEXITY CALCULATION

Divide and Conquer CISC4080, Computer Algorithms CIS, Fordham Univ. Acknowledgement. Outline

Design and Analysis of Algorithms PART III

CSE 326: Data Structures Sorting Conclusion

CS Sorting Terms & Definitions. Comparing Sorting Algorithms. Bubble Sort. Bubble Sort: Graphical Trace

Run Times. Efficiency Issues. Run Times cont d. More on O( ) notation

Introduction to Algorithms

CSC Design and Analysis of Algorithms

CSE 332: Data Structures & Parallelism Lecture 12: Comparison Sorting. Ruth Anderson Winter 2019

Sorting. CMPS 2200 Fall Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk

Real-world sorting (not on exam)

Introduction to Algorithms October 12, 2005 Massachusetts Institute of Technology Professors Erik D. Demaine and Charles E. Leiserson Quiz 1.

Transcription:

Data Structures Sorting Haim Kaplan & Uri Zwick December 2013 1

Comparison based sorting key a 1 a 2 a n info Input: An array containing n items Keys belong to a totally ordered domain Two keys can be compared in O(1) time Output: The array with the items reordered so that a 1 a 2 a n in-place sorting info may contain initial position

Comparison based sorting Insertion sort Bubble sort Balanced search trees Heapsort Merge sort Quicksort O(n 2 ) O(n log n) O(n log n) expected time

Warm-up: Insertion sort Worst case O(n 2 ) Best case O(n) Efficient for small values of n

Warm-up: Insertion sort Slightly optimized. Worst case still O(n 2 ) Even more efficient for small values of n

Warm-up: Insertion sort (Adapted from Bentley s Programming Peals, Second Edition, p. 116.)

AlgoRythmics Insertion sort Bubble sort Select sort Shell sort Merge sort Quicksort 7

One of the 10 algorithms with the greatest influence on the development and practice of science and engineering in the 20th century. Quicksort [Hoare (1961)] Winner of the 1980 Turing award 8

Quicksort < A[p] A[p] 9

partition If A[j] A[r] < A[r] A[r] < A[r] A[r] 10

partition If A[j] < A[r] < A[r] A[r] < A[r] A[r] 11

p r < A[r] A[r] Lomuto s partition 12

partition 2 8 7 1 3 5 6 4 2 8 7 1 3 5 6 4 2 8 7 1 3 5 6 4 2 8 7 1 3 5 6 4 2 1 7 8 3 5 6 4 Use last key as pivot (Is it a good choice?) i last key < A[r] j next key to inspect 13

i 2 1 7 8 3 5 6 4 j i j 2 1 3 8 7 5 6 4 i j 2 1 3 8 7 5 6 4 i j 2 1 3 8 7 5 6 4 i j 2 1 3 4 7 5 6 8 Move pivot into position 14

Hoare s partition A[r] A[r] Performs less swaps than Lomuto s partition Produces a more balanced partition when keys contain repetitions. Used in practice 15

Hoare s partition A[i] < A[r] A[r] A[r] A[r] A[r] 16

Hoare s partition A[j] > A[r] A[r] A[r] A[r] A[r] 17

Hoare s partition A[i] A[r], A[j] A[r] A[r] A[r] A[r] A[r] 18

Analysis of quicksort Best case: n (n 1)/2, 1, (n 1)/2 Worst case: n n 1, 1, 0 Average case: n i 1, 1, n i where i is chosen randomly from {1,2,,n} Worst case obtained when array is sorted Average case obtained when array is in random order Let C n be the number of comparisons performed 19

Best case of quicksort By easy induction 20

Best case of quicksort 21

Fairly good case of quicksort 22

Worst case of quicksort By easy induction 23

Worst case of quicksort Worst case is really bad Obtained when array is sorted 24

How do we avoid the worst case? Use a random item as pivot Running time is now a random variable Average case now obtained for any input For any input, bad behavior is extremely unlikely For simplicity, we consider the expected running time, or more precisely, expected number of comparisons 25

Randomized quicksort (How do we generate random numbers?) 26

Analysis of (rand-)quicksort using recurrence relations P2C2E (Actually, not that complicated) 27

Analysis of (rand-)quicksort 28

Analysis of (rand-)quicksort Let the input keys be z 1 < z 2 < < z n Proof by induction on the size of the array Basis: If n=2, then i=1 and j=2, and the probability that z 1 and z 2 are compared is indeed 1 29

Analysis of (rand-)quicksort Induction step: Suppose result holds for all arrays of size < n Let z k be the chosen pivot key The probability that z i and z j are compared, given that z k is the pivot element 30

Analysis of (rand-)quicksort Let z k be the chosen pivot key If k<i, both z i and z j will be in the right sub-array, without being compared during the partition. In the right sub-array they are now z i k and z j k. If k>j, both z i and z j will be in the left sub-array, without being compared during the partition. In the left sub-array they are now z i and z j. If k=i or k=j, then z i and z j are compared If i<k<j, then z i and z j are not compared 31

Analysis of (rand-)quicksort (by induction) (by induction) 32

Analysis of (rand-)quicksort 33

Analysis of (rand-)quicksort Exact version 34

Lower bound for comparison-based sorting algorithms 35

The comparison model Items to be sorted a 1, a 2,, a n i : j < Sorting algorithm The only access that the algorithm has to the input is via comparisons 36

comparison-based sorting algorithm comparison tree

Insertion sort x y z x:y < > x y z y:z x:z y x z < > > x y z x:z x z y y x z y:z y z x < > < > x z y z x y y z x z y x

Quicksort < x:z x y z > y:z y:z < > < > x y z x:y x z y y z x x:y z x y < > < > x y z y x z z x y z y x

Comparison trees Every comparison-based sorting algorithm can be converted into a comparison tree. Comparison trees are binary trees The comparison tree of a (correct) sorting algorithm has n! leaves. (Note: the size of a comparison tree is huge. We are only using comparison trees in proofs.) 40

Comparison trees A run of the sorting algorithm corresponds to a root-leaf path in the comparison tree Maximum number of comparisons is therefore the height of the tree Average number of comparisons, over all input orders, is the average depth of leaves 41

Depth and average depth 1 Height = 3 (maximal depth of leaf) 3 3 2 Average depth of leaves = (1+2+3+3)/4 = 9/4 42

Maximum and average depth of trees Lemma 2, of course, implies Lemma 1 Lemma 1 is obvious: a tree of depth k contains at most 2 k leaves 43

Average depth of trees Proof by induction (by induction) (by convexity of x log x) 44

Convexity 45

Lower bounds Theorem 1: Any comparison-based sorting algorithm must perform at least log 2 (n!) comparisons on some input. Theorem 2: The average number of comparisons, over all input orders, performed by any comparisonbased sorting algorithm is at least log 2 (n!). 46

Stirling formula 47

Approximating sums by integrals f increasing 48

Randomized algorithms The lower bounds we proved so far apply only to deterministic algorithms Maybe there is a randomized comparison-based algorithm that performs an expected number of o(n log n) comparisons on any input? 49

Randomized algorithms A randomized algorithm R may be viewed as a probability distribution over deterministic algorithms R: Run D i with probability p i, for 1 i N (Perform all the random choices in advance) 50

Notation R: Run D i with probability p i, for 1 i N R(x) - number of comparisons performed by R on input x (random variable) D i (x) - number of comparisons performed by D i on input x (number) 51

More notation + Important observation R: Run D i with probability p i, for 1 i N

Randomized algorithms If the expected number of comparisons performed by R is at most f(n) for every input x, then the expected number of comparisons performed by R on a random input is also at most f(n) That means that there is also a deterministic algorithms D i whose expected number of comparisons on a random input is at most f(n) Thus f(n) = (n log n) 53

Randomized algorithms 54

Lower bounds Theorem 1: Any comparison-based sorting algorithm must perform at least log 2 (n!) comparisons on some input. Theorem 2: The average number of comparisons, over all input orders, performed by any comparisonbased sorting algorithm is at least log 2 (n!). Theorem 3: Any randomized comparison-based sorting algorithm must perform an expected number of at least log 2 (n!) comparisons on some input. 55

Beating the lower bound We can beat the lower bound if we can deduce order relations between keys not by comparisons Examples: Count sort Radix sort 56

Count sort Assume that keys are integers between 0 and R 1 A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 0 57

Count sort Allocate a temporary array of size R: cell i counts the # of keys = i A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 C 0 0 0 0 0 0 0 1 2 3 4 5 58

Count sort A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 C 0 0 1 0 0 0 0 1 2 3 4 5 59

Count sort A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 C 0 0 1 1 0 0 0 1 2 3 4 5 60

Count sort A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 C 1 0 1 1 0 0 0 1 2 3 4 5 61

Count sort A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 C 2 0 2 2 0 3 0 1 2 3 4 5 62

Count sort Compute the prefix sums of C: cell i now holds the # of keys i A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 C 2 0 2 2 0 3 0 1 2 3 4 5 63

Count sort Compute the prefix sums of C: cell i now holds the # of keys i A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 C 2 2 4 6 6 9 0 1 2 3 4 5 64

Count sort Move items to output array A C 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 0 1 2 3 4 5 2 2 4 6 6 9 B 0 1 2 3 4 5 6 7 8 / / / / / / / / / 65

Count sort A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 C 0 1 2 3 4 5 2 2 4 6 6 9 B 0 1 2 3 4 5 6 7 8 / / / / / / / / / 66

Count sort A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 C 0 1 2 3 4 5 2 2 4 6 6 8 B 0 1 2 3 4 5 6 7 8 / / / / / / / / 5 67

Count sort A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 C 0 1 2 3 4 5 2 2 3 6 6 8 B 0 1 2 3 4 5 6 7 8 / / / 2 / / / / 5 68

Count sort A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 C 0 1 2 3 4 5 1 2 3 6 6 8 B 0 1 2 3 4 5 6 7 8 / 0 / 2 / / / / 5 69

Count sort A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 C 0 1 2 3 4 5 1 2 3 6 6 7 B 0 1 2 3 4 5 6 7 8 / 0 / 2 / / / 5 5 70

Count sort A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 C 0 1 2 3 4 5 1 2 3 5 6 7 B 0 1 2 3 4 5 6 7 8 / 0 / 2 / 3 / 5 5 71

Count sort A 0 1 2 3 4 5 6 7 8 2 3 0 5 3 5 0 2 5 C 0 1 2 3 4 5 0 2 2 4 6 6 B 0 1 2 3 4 5 6 7 8 0 0 2 2 3 3 5 5 5 72

(Adapted from Cormen, Leiserson, Rivest and Stein, Introduction to Algorithms, Third Edition, 2009, p. 195)

Count sort Complexity: O(n+R) In particular, we can sort n integers in the range {0,1,,cn} in O(cn) time Count sort is stable No comparisons performed 74

Stable sorting algorithms key a a a info x y z key a a a info x y z Order of items with same key should be preserved Is quicksort stable? No.

Radix sort Want to sort numbers with d digits each between 0 and R 1 2 8 7 1 4 5 9 1 6 5 7 2 1 3 0 1 2 4 7 2 3 5 5 5 7 0 2 2 8 3 9 4 4 8 4 4 3 5 3 6 76

LSD Radix sort Use a stable sort, e.g. count sort, to sort by the Least Significant Digit 2 8 7 1 4 5 9 1 6 5 7 2 1 3 0 1 2 4 7 2 3 5 5 5 7 0 2 2 8 3 9 4 4 8 4 4 3 5 3 6 77

LSD Radix sort 2 8 7 1 4 5 9 1 6 5 7 2 1 3 0 1 2 4 7 2 3 5 5 5 7 0 2 2 8 3 9 4 4 8 4 4 3 5 3 6 2 8 7 1 4 5 9 1 1 3 0 1 6 5 7 2 2 4 7 2 7 0 2 2 8 3 9 4 4 8 4 4 3 5 5 5 3 5 3 6 78

LSD Radix sort 2 8 7 1 4 5 9 1 6 5 7 2 1 3 0 1 2 4 7 2 3 5 5 5 7 0 2 2 8 3 9 4 4 8 4 4 3 5 3 6 2 8 7 1 4 5 9 1 1 3 0 1 6 5 7 2 2 4 7 2 7 0 2 2 8 3 9 4 4 8 4 4 3 5 5 5 3 5 3 6 79

LSD Radix sort 2 8 7 1 4 5 9 1 6 5 7 2 1 3 0 1 2 4 7 2 3 5 5 5 7 0 2 2 8 3 9 4 4 8 4 4 3 5 3 6 2 8 7 1 4 5 9 1 1 3 0 1 6 5 7 2 2 4 7 2 7 0 2 2 8 3 9 4 4 8 4 4 3 5 5 5 3 5 3 6 1 3 0 1 7 0 2 2 3 5 3 6 4 8 4 4 3 5 5 5 2 8 7 1 6 5 7 2 2 4 7 2 4 5 9 1 8 3 9 4 80

LSD Radix sort 2 8 7 1 4 5 9 1 6 5 7 2 1 3 0 1 2 4 7 2 3 5 5 5 7 0 2 2 8 3 9 4 4 8 4 4 3 5 3 6 2 8 7 1 4 5 9 1 1 3 0 1 6 5 7 2 2 4 7 2 7 0 2 2 8 3 9 4 4 8 4 4 3 5 5 5 3 5 3 6 1 3 0 1 7 0 2 2 3 5 3 6 4 8 4 4 3 5 5 5 2 8 7 1 6 5 7 2 2 4 7 2 4 5 9 1 8 3 9 4 81

LSD Radix sort 2 8 7 1 2 8 7 1 1 3 0 1 7 0 2 2 4 5 9 1 4 5 9 1 7 0 2 2 1 3 0 1 6 5 7 2 1 3 0 1 3 5 3 6 8 3 9 4 1 3 0 1 6 5 7 2 4 8 4 4 2 4 7 2 2 4 7 2 2 4 7 2 3 5 5 5 3 5 3 6 3 5 5 5 7 0 2 2 2 8 7 1 3 5 5 5 7 0 2 2 8 3 9 4 6 5 7 2 6 5 7 2 8 3 9 4 4 8 4 4 2 4 7 2 4 5 9 1 4 8 4 4 3 5 5 5 4 5 9 1 4 8 4 4 3 5 3 6 3 5 3 6 8 3 9 4 2 8 7 1 82

LSD Radix sort 2 8 7 1 2 8 7 1 1 3 0 1 7 0 2 2 4 5 9 1 4 5 9 1 7 0 2 2 1 3 0 1 6 5 7 2 1 3 0 1 3 5 3 6 8 3 9 4 1 3 0 1 6 5 7 2 4 8 4 4 2 4 7 2 2 4 7 2 2 4 7 2 3 5 5 5 3 5 3 6 3 5 5 5 7 0 2 2 2 8 7 1 3 5 5 5 7 0 2 2 8 3 9 4 6 5 7 2 6 5 7 2 8 3 9 4 4 8 4 4 2 4 7 2 4 5 9 1 4 8 4 4 3 5 5 5 4 5 9 1 4 8 4 4 3 5 3 6 3 5 3 6 8 3 9 4 2 8 7 1 83

LSD Radix sort 2 8 7 1 2 8 7 1 1 3 0 1 7 0 2 2 1 3 0 1 4 5 9 1 4 5 9 1 7 0 2 2 1 3 0 1 2 4 7 2 6 5 7 2 1 3 0 1 3 5 3 6 8 3 9 4 2 8 7 1 1 3 0 1 6 5 7 2 4 8 4 4 2 4 7 2 3 5 3 6 2 4 7 2 2 4 7 2 3 5 5 5 3 5 3 6 3 5 5 5 3 5 5 5 7 0 2 2 2 8 7 1 3 5 5 5 4 5 9 1 7 0 2 2 8 3 9 4 6 5 7 2 6 5 7 2 4 8 4 4 8 3 9 4 4 8 4 4 2 4 7 2 4 5 9 1 6 5 7 2 4 8 4 4 3 5 5 5 4 5 9 1 4 8 4 4 7 0 2 2 3 5 3 6 3 5 3 6 8 3 9 4 2 8 7 1 8 3 9 4 84

LSD Radix sort Complexity: O(d(n+R)) In particular, we can sort n integers in the range {0,1,, n d 1} in O(dn) time (View each number as a d digit number in base n) In practice, choose R to be a power of two Edge digit extracted using simple bit operations 85

Extracting digits In R=2 r, the operation is especially efficient: r bits r bits 86

Word-RAM model Each machine word holds w bits In constant time, we can perform any usual operation on two machine words, e.g., addition, multiplication, logical operations, shifts, etc. Open problem: Can we sort n words in O(n) time? 87