-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fallback on oneWay scan once the input size is below a certain threshold #20
Comments
If we want it to stay below linear time we should wait until subproblems are roughly cubic root sized. |
Incorrect! |
Explicit stack management (#24) allows us to prune the recursion tree at some height and resume rectangle splitting outside Hirschberg's recursion. |
To record the entire DP we need space for
To reconstruct the rectangles we backtrack the pointers. We can either fill a stack to consume later or reverse the direction of pointers while backtracking, so that we can read the information in correct order in a second, forward, pass. To record these informations, we modify the algorithm so that:
The time complexity is unchanged but the space complexity is now Instead of a one-way scan we can also use a two-way scan. This potentially reduces the amount of explored cells by a factor of two. Also the backward scan does not need a stack or reversing pointers since rectangles come in the correct order. Maybe some usages do not require rectangles to be output in sorted order? We can simulate a heap on top of already allocated memory (pointers are simply addresses in the allocated memory). |
Depending on N or N+M?
oneWay
needs MAX^2 space and D^2 time whereastwoWay
needs MAX space and (D^2)/2 time on the first pass, D^2 in total. CurrenttwoWay
implementation scans middle snake twice, hence potentially 2 * D^2 total. We have to wait at least until the square root of the input size so that we can reuse pre-allocated memory.We could also have a
twoWay
scan that saves the complete history in quadratic space to exploit the potential 1/2 time/space reduction.Related: #19.
The text was updated successfully, but these errors were encountered: