Question: [ 30 points] public Iterator preOrderlterator() The method returns an iterator that performs the preorder traversal on the tree. The iterator must be dynamic in

 [ 30 points] public Iterator preOrderlterator() The method returns an iterator

[ 30 points] public Iterator preOrderlterator() The method returns an iterator that performs the preorder traversal on the tree. The iterator must be dynamic in the following sense: if after the iterator is created, and the tree changes in some part that has not been processed by the iterator yet, then the iterator "will see" these changes and output the values in the updated tree when reaching that part of the tree. However, if you change the nodes that have already been processed, then it wil have no effect on the iterator. ** Be careful, do not change the nodes that are currently being processed, as this may have unexpected effects This means you cannot simply create the list with the preorder traversal of the tree in the constructor of the iterator. It will not work in the dynamic sense. You will probably need to implement the iterator in a new class. Please declare the class in the package binarytree. Make sure to submit the java file implementing the iterator

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!