Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am working on this project for a java class, I am having difficulties with part 2 where we need to return an iterator. I
I am working on this project for a java class, I am having difficulties with part 2 where we need to return an iterator. I do not know how to go about doing this, some tips would be helpful or some code in java or rough outline. I have part 1 complete for the most part and I believe it is correct. Thanks.
Part 1: K-ary Tree Basic Structure The following methods are required to build a basic K-ary tree public KTree (E[] arrayTree, int k) Description: o Constructs a k-ary tree from thc given array with the branching factor k Inputs: arrayTree stores the tree in level order and the root is stored at index 0. Missing elements will be denoted by null values o o k is the branching factor of the k-ary tree Additional Requirements: You must copy the clements from the array into your internal storage, do not just store the array if you are using an array-based representation Throw an InvalidKException if k tree new KTree (strings, 2); - - Notes: o You may add @suppresswarnings ('' unchecked") f necessary public int getK) o Returns the k value of the treee public int size () Returns the number of elements in the tree public int height) Returns the height of the k-ary tree public E get (int i) Description: o This method will accept an location (i) and returns the value at that location o i the level-order location of the node if the tree was perfect (aka. full and complete) o The valuc at location i o O(1) for array-based representations O(n) for link-based representations Input: Returns: . Additional Requirements: o Throw an IllegalArgumentException if i is not a node in the tree * Lxamples: Integer[1 input-0, null, 2, null, null, 5, 6; KTreeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started