TAOCP Vol 3: Sorting and Searching · Week 104

TAOCP 5.4.5 The Oscillating Sort

Updated

About 3 hours5 exercises, rated 21 to 29

Summary

TAOCP 5.4.5 The Oscillating Sort: A tape sorting scheme that interleaves run creation and merging so the sort oscillates between phases, reducing tape movement. Budget about 3 hours; do exercises 4, 1 and 5.

Flashcards 9 cards for Anki and AnkiMobile · all decks

Anki deck.tsv

This week's steps

3 steps
  1. Read §5.4.5 The Oscillating Sort

    Skim.

  2. Work the exercises (4 picked)

    Start with Ex 4, Ex 1, Ex 5; log what you solve below.

  3. Write down one thing you'd explain to someone

    A few sentences in your own words in Your notes: the idea, why it works, an example. 30 words ticks this.

Sign in to track this: tick each step off and it counts toward your week.

Exercises

This section has 5 exercises, rated 21 to 29, and Knuth marks 1 of them with the triangle for recommended. Only five exercises, so do all of them. 3 is the meaty one: chart Algorithm B on a small case and find where it wastes work.

Worth your time

  • Exercise 122

    Specify Sobel's original oscillating sort precisely for any number of tapes.

    Discuss

  • Exercise 329▶ Recommended

    Chart Algorithm B on three tapes and nine runs, spot the inefficiency and fix it.

    Discuss

  • Exercise 421

    Show one of two table updates in Algorithm B is never read.

    Discuss

  • Exercise 5M25

    Which run counts let Algorithm B avoid rewinding? The math one.

    Discuss

Your log

Sign in to log the exercises you work: number, rating, how far you got.

Your notes

Only you

Sign in to keep private notes on this guide, in Markdown. They stay yours: never on your profile, and you can export them all.

Discussion

0 posts

Questions about the reading go here; each exercise has its own thread below. Hints over answers.

No posts yet. Ask a question or share a tip.

Sign in to postAnyone can read. Posting needs an account with a confirmed email.

Exercise threads

One thread per exercise. Open one to ask for a nudge or check your thinking.

  • Exercise 122No posts yet

    Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler: ||like this|| or a ```spoiler block.

    Sign in to postAnyone can read. Posting needs an account with a confirmed email.

  • Exercise 329No posts yet

    Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler: ||like this|| or a ```spoiler block.

    Sign in to postAnyone can read. Posting needs an account with a confirmed email.

  • Exercise 421No posts yet

    Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler: ||like this|| or a ```spoiler block.

    Sign in to postAnyone can read. Posting needs an account with a confirmed email.

  • Exercise 5M25No posts yet

    Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler: ||like this|| or a ```spoiler block.

    Sign in to postAnyone can read. Posting needs an account with a confirmed email.

Reference

Why it matters

Honest note: the tape-merging sections describe hardware nobody uses anymore. Knuth himself says much of 5.4 is historical. The ideas (run generation, merge patterns, minimizing passes over slow storage) still apply to external sorting on disks and SSDs, database sort operators and big-data shuffles, so read for those ideas and skim the tape mechanics.

Before you start
  • 5.4.4 Reading Tape Backwards
How to approach it

Skim.

Spot a mistake? Report it

Back to week 104