Homework08
A MathWikiből
(Változatok közti eltérés)
(Új oldal, tartalma: „==Problem 1: Path== Write an <tt>path(self)</tt> method for the class Tree which returns True if the tree is a long path without a junction. False otherwise. The tree i…”) |
(→Problem 1: Path) |
||
1. sor: | 1. sor: | ||
− | ==Problem 1: | + | ==Problem 1: New Tree Methods== |
− | Write an <tt> | + | *Write an <tt>is_path(self)</tt> method for the class Tree which returns True if the tree is a long path without a junction. False otherwise. The tree is a path if all of the nodes <b>except the root</b> have at most one branches. |
+ | *Write a <tt>path(self)</tt> method for the class Tree which returns all paths from the leaves to the root of a given binary tree. | ||
+ | |||
+ | ==Problem 2: Proper Calculator== | ||
+ | Write modify the calculator in the exercise to handle parantheses such that it calculates the input based on the parentheses. | ||
+ | |||
+ | Example: | ||
+ | 2+(7*3) --> 23 | ||
+ | (2+7)*3 --> 27 | ||
+ | |||
+ | ==Note== | ||
+ | each problem counts for 2 points |
A lap 2021. május 4., 21:10-kori változata
Problem 1: New Tree Methods
- Write an is_path(self) method for the class Tree which returns True if the tree is a long path without a junction. False otherwise. The tree is a path if all of the nodes except the root have at most one branches.
- Write a path(self) method for the class Tree which returns all paths from the leaves to the root of a given binary tree.
Problem 2: Proper Calculator
Write modify the calculator in the exercise to handle parantheses such that it calculates the input based on the parentheses.
Example:
2+(7*3) --> 23 (2+7)*3 --> 27
Note
each problem counts for 2 points