Homework08

A MathWikiből
(Változatok közti eltérés)
(Problem 1: Path)
(Problem 1: New Tree Methods)
1. sor: 1. sor:
 +
[[Informatics2-2021|Home]]
 
==Problem 1: New Tree Methods==
 
==Problem 1: New Tree Methods==
 
*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 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.

A lap 2021. május 4., 21:11-kori változata

Home

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

Személyes eszközök