Commit f17a49ea by Pietro Abate

### Refine solution for red-black trees

parent f6ccb7ff
 ... ... @@ -13,6 +13,7 @@ type Wrongtree('a) = Rtree('a) ; 'b\Unbalanced('a) -> 'b\Unbalanced('a) ) | [ [ [ a b ] c ] d ] | [ [ a [ b c ] ] d ] ... ... @@ -20,6 +21,32 @@ let balance ( Unbalanced('a) -> Rtree('a) ; 'b\Unbalanced('a) -> 'b\Unbalanced(' | [ a [ b [ c d ] ] ] -> [ [ a b ] [ c d ] ] | x -> x ;; let balance ( Unbalanced('a) -> Rtree('a) ; 'b & RBtree('a) -> 'b & RBtree('a) ) | [ [ [ a b ] c ] d ] | [ [ a [ b c ] ] d ] | [ a [ [ b c ] d ] ] | [ a [ b [ c d ] ] ] -> [ [ a b ] [ c d ] ] | x -> x ;; let balance ( Unbalanced('a) -> Rtree('a) ; 'b\Unbalanced(Any) -> 'b\Unbalanced(Any) ) | ([ [ [ a b ] c ] d ] | [ [ a [ b c ] ] d ] | [ a [ [ b c ] d ] ] | [ a [ b [ c d ] ] ]) & Unbalanced(Any) -> [ [ a b ] [ c d ] ] | x -> x ;; type UTree = [ [ [ Any Any ] Any ] Any ] | [ [ Any [ Any Any ] ] Any ] | [ Any [ [ Any Any ] Any ] ] | [ Any [ Any [ Any Any ] ] ] ;; let insert (x : 'a) (t : Btree('a)) : Btree('a) = let ins_aux ( [] -> Rtree('a); ... ... @@ -32,4 +59,4 @@ let insert (x : 'a) (t : Btree('a)) : Btree('a) = else z in match ins_aux t with | <_ (y)>[ a b ] -> [ a b ] \ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!