Copyright | Copyright (C) 2021 Yoo Chung |
---|---|
License | GPL-3.0-or-later |
Maintainer | dev@chungyc.org |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Problems.P66
Description
Part of Ninety-Nine Haskell Problems. Some solutions are in Solutions.P66.
Synopsis
- layoutCompact :: Tree a -> Tree (a, (Int, Int))
Documentation
layoutCompact :: Tree a -> Tree (a, (Int, Int)) Source #
Yet another layout strategy is shown in the illustration below:
The method yields a very compact layout while maintaining a certain symmetry in every node. Find out the rules and write the corresponding function. Use the same conventions as in Problems.P64 and Problems.P65.
Examples
>>>
layoutCompact tree65
Branch ('n',(5,1)) (Branch ('k',(3,2)) (Branch ('c',(2,3)) ...
Hint
Consider the horizontal distance between a node and its successor nodes. How tight can you pack together two subtrees to construct the combined binary tree?