CSC148H1 Study Guide - Midterm Guide: Arity, Branching Factor, Init

79 views6 pages
25 Oct 2018
School
Course
Professor
katrinasavvy and 38715 others unlocked
CSC148H1 Full Course Notes
1
CSC148H1 Full Course Notes
Verified Note
1 document

Document Summary

Recall that we dened the height of a tree in such a way that a tree consisting of just the root has a height of 1. Suppose we have a tree of height 3 with a branching factor (arity) of 3. (i) the greatest number of nodes this tree could have is: Use a diagram to justify your answer: sample solution. The greatest number of nodes is 13: 1 at level zero, 3 at level one, and 9 at level three. (ii) the least number of nodes this tree could have is: The least number of nodes is 3: the root, with a right child that also has a right child. Notice that it is not a binary search tree. Write the values below in the correct order. sample solution: Read over the declaration of class btnode and the docstring for function list leaves between: class btnode: """binary tree node. """ def __init__(self, data, left=none, right=none):