Copyright | Copyright (C) 2021 Yoo Chung |
---|---|
License | GPL-3.0-or-later |
Maintainer | dev@chungyc.org |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Part of Ninety-Nine Haskell Problems. Some solutions are in Solutions.P68.
Documentation
inorder :: Tree a -> [a] Source #
Return the in-order sequence of a binary tree.
Examples
>>>
inorder tree1
"dbeacgf"
preorder :: Tree a -> [a] Source #
Return the pre-order sequence of a binary tree.
Examples
>>>
preorder tree1
"abdecfg"
:: Eq a | |
=> [a] | In-order sequence |
-> [a] | Pre-order sequence |
-> Maybe (Tree a) | Binary tree with the given in-order and pre-order sequences |
Given the in-order and pre-order sequences of a binary tree, return the original binary tree.
The values in each node of the binary tree will be distinct, in which case the tree is determined unambiguously.
Examples
>>>
ordersToTree "dbeacgf" "abdecfg" == Just tree1
True