Question: ` ` ` fron Node 2 3 4 import Node 2 3 4 class Tree 2 3 4 Iterator: def _ _ init _ _
fron Node import Node
class TreeIterator:
def initself root:
Your code here remove placeholder Line below
self.nodestack
self.currentnode root
self.currentkeyindex
while self.currentnode is not None:
self.nodestack.appendselfcurrentnode, self.currentkeyindex
self.currentnode self.currentnode.getchildselfcurrentkeyindex
self.currentkeyindex if self.currentnode is not None else e
l Returns the tree's next key, or raises StopIteration if no more keys exist
def nextself:
Your code here remove placeholder Line below
if not self.nodestack:
raise StopIteration
currentnode, currentkeyindex self.nodestack.pop
key currentnode.getkeycurrentkeyindex
self.currentkeyindex
while currentnode.isinternal and self.currentkeyindex currentnode.getnumkey:
child currentnode.getchildselfcurrentkeyindex
self.nodestack.appendcurrentnode, self.currentkeyindex
currentnode child
self.currentkeyindex
return key
#defiterseLf
return self
inter program input optional
fyour code requires input values, provide them here.
Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box.
rogram errors displayed here
Traceback most recent call last:
File homerunnerlocalsubmissionmainpy line in
main
File homerunnerlocalsubmissionmainpy line in main
for actualint in tree:
File homerunnerlocalsubmissionTreeIteratorpy line in next
while currentnode.isinternal and self.currentkeyindex currentnode.getnumkey:
AttributeError: 'Node object has no attribute isinternal'
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
