Hacker News new | ask | show | jobs
by sksk 1928 days ago
I am not so sure. With normal order, if I want to get to page 63 out of 100 pages, I will randomly pick the middle and scan linearly until I hit 63.

With this one, I know the last page is around 50 in the normal order. So I will just invert the stack and scan linearly for 63 from the bottom.

2 comments

Also is you want to jump to page 63 its not enough to find the place to jump to, you also need to flip each page individually and put in back of the stack to have proper ordering. You cant just take stack of 62 pages and put in to the bottom.
And if you don't know exactly how many pages there are? Normaly you would just do binary search.
If pages are numbered, the largest page number is still on last page. Just look there.

Or alternatively: The first step of your binary search is to look at the page number on the flip side of page 1 and determine to flip the stack or not.