Store every power of two
transcript
A reply thread is a hundred thousand deep. You get a hundred thousand questions. Each asks for the k-th reply above. Following links is far too slow.
There are a hundred thousand questions. Each might follow a hundred thousand links. That is ten billion steps in all. A judge runs a hundred million a second.
A jump of thirteen is eight, four and one. So store the jump of every power of two. Then any jump is a few reads.
Row zero is the parents. Row one jumps two steps. Row two jumps four steps. Each row comes from the row before.
Write k in binary. Take one jump for each set bit. That is at most seventeen reads.
The table has seventeen rows. Each row has a hundred thousand entries. That is one point seven million in all.
Build the table once. Each row doubles the jump. Any k becomes a few reads. Ten billion becomes seventeen. Full breakdown in the lecture.