Todos los libros

Profesional

Apps Acerca de Coach Iniciar sesión Empezar a leer

Computer Science · Glosario

¿Qué es Quicksort, pivot, three-way partition?

También llamado: quicksort · pivot · three-way partition (of an array)

Definition 19.4 University Computer Science — Year 1 · Capítulo 19 — Sorting

Quicksort chooses an element, the pivot, partitions the array into the elements smaller than the pivot, the pivot, and the others, and sorts the two parts recursively. A three-way partition separates the elements smaller than, equal to and larger than the pivot.

Quicksort of [7, 2, 9, 4, 1, 8, 5]: the first partition puts 5 (shaded) in its final place, with 2, 4, 1 on its left and 9, 8, 7 on its right; the parts are sorted in the same way. In all 6 + 2 + 1 + 2 + 1 = 12 comparisons.
Quicksort of [7,2,9,4,1,8,5][7, 2, 9, 4, 1, 8, 5]: the first partition puts 5 (shaded) in its final place, with 2, 4, 1 on its left and 9, 8, 7 on its right; the parts are sorted in the same way. In all 6+2+1+2+1=126 + 2 + 1 + 2 + 1 = 12 comparisons.
Leer en el capítulo →