CS 411 Fall 2025 > Outline for October 17, 2025
CS 411 Fall 2025
Outline
for October 17, 2025
Outline
Space-Time Trade-Offs [L Ch 7 intro]
- Idea: Allow an algorithm to use extra space,
in order to save time.
  - Very common strategy.
 
- Examples you might have seen:
  - Merge Sort on an array: use a buffer.
- Caching: disk blocks in memory, memory contents on processor.
- Save result of a computation to avoid recomputing.
 
- We will look at:
  - Input enhancement
    - Preprocess input, store info about it to allow for faster code.
 
- Prestructuring
    - Store input in form that requires more space, but allows for faster access.
 
- Dynamic programming
    - Method for speeding up some recursive (or conceptually recursive) algorithms.
- Save results of previous computations so that they do not need to be done again.
- Often applied to optimization problems.
- The text devotes a separate chapter to dynamic programming [L Ch 8].
 
 
- Input enhancement
    
Sorting by Counting [L 7.1]
- Can sort list by determining, for each item, how many items come before it.
- Naive implementation: \(\Theta(n^2)\) comparisons.
- If values in list can index an array,
then can greatly improve performance by storing array of counts.
  - \(n\) is number of items to sort, basic ops are array look-ups & integer operations.
- For an array whose values are integers in the range \([1,k]\), algorithm uses \(\Theta(k+n)\) ops.
- For fixed set of integer values, only \(\Theta(n)\) ops!
- This improvement is not a comparison sort.