全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Comparison tree?

Definition 19.8 University Computer Science — Year 1 · 第 19 章 — Sorting

The comparison tree of a comparison sort for inputs of size nn is the binary tree whose internal nodes are the comparisons the sort makes, with one subtree for each outcome, and whose leaves are the outputs. An input follows one path from the root to a leaf; the length of the path is the number of comparisons.

The comparison tree of insertion sort on three keys a, b, c: six leaves, one for each order, and height 3. A sorted input takes the rightmost path, two comparisons.
The comparison tree of insertion sort on three keys a,b,ca, b, c: six leaves, one for each order, and height 3. A sorted input takes the rightmost path, two comparisons.
Comparisons from , averaged over 200 random orders. Quicksort on sorted input leaves the chart at n = 36 (630 comparisons). Merge sort hugs the bound; heapsort makes about twice as many.
Comparisons from Output 19.4, averaged over 200 random orders. Quicksort on sorted input leaves the chart at n=36n = 36 (630 comparisons). Merge sort hugs the bound; heapsort makes about twice as many.
在原文中阅读 →