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

`>>>`

"dbeacgf"`inorder tree1`

preorder :: Tree a -> [a] Source #

Return the pre-order sequence of a binary tree.

### Examples

`>>>`

"abdecfg"`preorder tree1`

:: 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

`>>>`

True`ordersToTree "dbeacgf" "abdecfg" == Just tree1`