KW.pm The Schwartzian Transform #4

Why?

  • allows you to sort a list (n) by some non-apparent feature func(n)

  • general idea:

    1. Construct data structure with both (n) and func(n)

    2. Sort by func(n)

    3. Optionally throw away func(n) and make output

  • efficiency: only need to build func(n) once.

    1. O(n) time vs. O(n log n) time

 

<< Previous | Index | Next >> Copyright © 2003 Daniel Allen