Contents | Up | Prev | Next |

Freecell Solver - Evolution of a C Program → Evolution of the States' Collection → Binary-Search-Based Merge to Add the Sort Margin

- Instead of qsorting the sort margin in, keep it sorted and then use a binary-search based merge to merge it with the main array.
- The reason I used a binary search based merge, instead of a linear merge, is because I reasoned that the main array would become much larger than the margin (which has a constant size), and so this would result in a lot of comparisons.
- O(log(n)) lookup, O(n) insertion, and O(n
^{2}) accumulative complexity. - Noticeably faster than qsorting.

Contents | Up | Prev | Next |

Written by Shlomi Fish