ninetynine-1.3.0: Ninety-Nine Haskell Problems
CopyrightCopyright (C) 2021 Yoo Chung
LicenseGPL-3.0-or-later
Maintainerdev@chungyc.org
Safe HaskellSafe-Inferred
LanguageGHC2021

Solutions.P68

Description

Some solutions to Problems.P68 of Ninety-Nine Haskell Problems.

Synopsis

Documentation

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

Return the pre-order sequence of a binary tree.

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

Return the in-order sequence of a binary tree.

ordersToTree Source #

Arguments

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