Created
October 4, 2016 16:43
-
-
Save BillyBadBoy/86df795c705e83b8dd4a29966fa2fa50 to your computer and use it in GitHub Desktop.
This file contains 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
balanceTree :: Tree -> Tree | |
balanceTree t = go $ (sort . tree2list) t | |
where go [] = Leaf | |
go ns = let m = length ns `div` 2 | |
in Node (ns !! m) (go $ take m ns) (go $ drop (m + 1) ns) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment