Created
December 7, 2013 06:14
-
-
Save catupper/7837854 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def merge(node): | |
| if node == NULL: return [] | |
| left = merge(node.left_child) | |
| right = merge(node.left_child) | |
| if len(left) < len(right): | |
| swap(left, right) #rightの方を小さくする | |
| res = combine(left, right) #O(RlogL) | |
| return res.insert(node.val) | |
| def combine(left, right): | |
| if right == 空:return left | |
| return combein(left.insert(right[0]), right[1:]) | |
| #len(N)へのinsertはlog(N)でできるとする | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment