Question: mplement the Tree 2 3 4 Iterator to satisfy the complexity requirements mentioned above. Code in LabProgram.java adds random keys to a Tree 2 3
mplement the TreeIterator to satisfy the complexity requirements mentioned above. Code in LabProgram.java adds random keys to a Tree object, then tests that the iterator properly iterates through all keys in ascending order. But time and space complexity aren't tested by LabProgram. LabProgram only ensures that the iterator properly iterates through all keys.
Most unit tests will fail if the iterator does not properly iterate through all the tree's keys in the correct order. So run code in develop mode and ensure that the test passes before submitting code.
The iterator never changes the tree in any way
Iteration starts at the tree's minimum key and ends at the maximum
Construction occurs in worstcase Olog N time
hasNext executes in worstcase O time
next executes in worstcase Olog N time
The iterator's space complexity is worstcase Olog Nimport java.util.;
public class TreeIterator implements Iterator
Your code here
public TreeIteratorNode treeRootNode
Your code here
public boolean hasNext
Your code here remove placeholder line below
return false;
public Integer next
Your code here remove placeholder line below
return ;
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
