Differences
This shows you the differences between two versions of the page.
|
pp:2026:scala:l05 [2026/03/25 09:28] ldaniel created |
pp:2026:scala:l05 [2026/03/25 09:30] (current) ldaniel sa puna arborele in main |
||
|---|---|---|---|
| Line 85: | Line 85: | ||
| } | } | ||
| </code> | </code> | ||
| + | |||
| + | Please copy-paste this definition in your ''Main.scala'' file from your laboratory project, in order for printTree to work properly. Call print from the function main and click the "run" text above the definition of main to see the result in terminal. | ||
| And arborică: | And arborică: | ||
| <code scala> | <code scala> | ||
| val arborica = Node(Node(leaf_node(-1), 5, TVoid), 1, Node(leaf_node(4), 2, Node(leaf_node(3), 6, leaf_node(7)))) | val arborica = Node(Node(leaf_node(-1), 5, TVoid), 1, Node(leaf_node(4), 2, Node(leaf_node(3), 6, leaf_node(7)))) | ||
| - | arborica.toStringTree | ||
| </code> | </code> | ||
| Line 116: | Line 117: | ||
| **(!) 5.3.5** Write a function which takes two BinaryTree and tries to assign the second tree as a child of the first. It should return a "container" of a BinaryTree . | **(!) 5.3.5** Write a function which takes two BinaryTree and tries to assign the second tree as a child of the first. It should return a "container" of a BinaryTree . | ||
| <code scala> | <code scala> | ||
| - | def append(tree1: BinaryTree, tree2: BinaryTree): Option[BTree] = ??? | + | def append(tree1: BinaryTree, tree2: BinaryTree): Option[BinaryTree] = ??? |
| </code> | </code> | ||