Some solutions from book "Purely functional data structures" by Chris Okasaki.