Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribedimage text in transcribed

image text in transcribed

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; KTree tree - new KTree (input, 2); tree.get (0) //returns 0 tree.get (1); //throw IllegalArgumentException tree.get (6) //returns

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions

Question

3. Provide advice on how to help a plateaued employee.

Answered: 1 week ago