Semua buku

Profesional

Aplikasi Tentang Pelatih Masuk Mulai membaca

Computer Science · Glosarium

Apa itu Selection problem, quickselect, median of medians?

Dikenal juga sebagai: selection problem · quickselect · median of medians

Definition 21.5 University Computer Science — Year 1 · Bab 21 — Divide and Conquer

The selection problem asks for the key of rank kk of nn keys, the one that would be at position kk if they were sorted; the median is the key of rank ⌊(n−1)/2⌋\lfloor (n - 1)/2 \rfloor. Quickselect partitions the keys around a pivot, as quicksort does, and goes on in the one part that holds rank kk. The median of medians chooses as pivot the median of the medians of groups of five keys, found by a recursive call.

Thirty-five keys in seven columns of five, columns ordered by their median; the circled key, the median of the medians, is the pivot. The shaded block below and left holds keys no larger than the pivot, the one above and right keys no smaller: each about 3/10 of all keys.
Thirty-five keys in seven columns of five, columns ordered by their median; the circled key, the median of the medians, is the pivot. The shaded block below and left holds keys no larger than the pivot, the one above and right keys no smaller: each about 3/103/10 of all keys.
Baca dalam konteks →