.py
files containing your work. (If you upload a screenshot or other file format, you won't get credit.)This homework assignment must be submitted in Gradescope by Noon central time on Tuesday 8 March 2022.
Collaboration is prohibited, and you may only access resources (books, online, etc.) listed below.
The course materials you may refer to for this homework are:
trees
subdirectory are of particular note.This homework assignment has two problems, numbered 2 and 3. The grading breakdown is:
Points | Item |
---|---|
2 | Autograder |
4 | Problem 2 |
4 | Problem 3 |
10 | Total |
The part marked "autograder" reflects points assigned to your submission based on some simple automated checks for Python syntax, etc.. The result of these checks is shown immediately after you submit.
Ask your instructor or TA a question by email, in office hours, or on discord.
In Gradescope, the score assigned to your homework submission by the autograder (checking for syntax and docstrings) will be recorded as "Problem 1". Therefore, the numbering of the actual problems begins with 2.
A node of a tree is called a leaf if it has no children.
Add a method leaves
to class Node
in hwk8.py
that, when called on the root of a tree, will find all leaf nodes in that tree and return a list of them. (So the return value should be a list of Node
objects.)
Add a method positive_keys
to class BST
in hwk8.py
that, when called on the root of a binary search tree containing floats or integers, will return a list of all the positive keys that appear in the binary search tree.