Created:

less than 1 minute read

⚠️ This post was created when I was in high school and is no longer maintained.

  • In terms of decision trees, we assume without loss of generality that all elements are distinct.
  • A decision tree is a full binary tree representing the element comparisons a specific sorting algorithm makes on an input of a given size.
  • Any correct sorting algorithm must be able to produce every permutation of its input. Each of the n! permutations on n elements appears as a leaf of the decision tree for a comparison sort to be correct.
  • Corollary 8.2: Heapsort and merge sort are asymptotically optimal comparison sorts.
    —— CLRS

4eef5df9b33bc1d137421c44a2f62241.png Tips for this figure:

  • The algorithm shown here is insertion sort, iterating with j and i = j - 1.

830527a737f2acc4dcd7ea46ac42d22f.png

  • the worst-case comparisons for a comparison algorithm = the height of the decision tree

c4b7d157fa2826cb1a80896fed278558.png

2ba0f65b8891fb5e16edeaf60bc8690a.png

Leave a comment