Last active
December 27, 2015 23:39
-
-
Save Centaur/7407815 to your computer and use it in GitHub Desktop.
practice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Tree | |
case object Empty extends Tree | |
case class Node(i: Int, left:Tree, right:Tree) extends Tree | |
def show(tree: Tree) : String // implement this method | |
/* Test Cases | |
show(Node(7, Node(3, Empty, Empty), Node(7, Empty, Empty))) | |
output: | |
7 | |
|--3 | |
`--7 | |
*/ | |
/* | |
show(Node(7, | |
(Node 2 | |
(Node 1 Empty Empty) | |
(Node 4 | |
(Node 3 Empty Empty) | |
(Node 6 Empty Empty))) | |
(Node 8 | |
Empty | |
(Node 21 | |
(Node 12 | |
Empty | |
Empty) | |
(Node 23 | |
Empty | |
Empty))) | |
output: | |
7 | |
|--2 | |
| |--1 | |
| `--4 | |
| |--3 | |
| `--6 | |
`--8 | |
`--21 | |
|--12 | |
`--23 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment