Question: In Java please: Part 1: K-ary Tree Basic Structure The following methods are required to build a basic K-ary tree: public KTree (E[1 arrayTree, int

In Java please:  In Java please: Part 1: K-ary Tree Basic Structure The following
methods are required to build a basic K-ary tree: public KTree (E[1

Part 1: K-ary Tree Basic Structure The following methods are required to build a basic K-ary tree: public KTree (E[1 arrayTree, int k) . Description: o Constructs a k-ary tree from the 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. k o is the branching factor of the k-ary tree . Additional Requirements: o You must copy the elements from the array into your internal storage, do not just store the array if you are using an array-based representation. Throw an InvalidKException ifk tree nw KTree (strings, 2) Notes: o You may add eSuppressWarnings ("unchecked") if necessary. public int getk ( . Returms the k value of the tree. 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 (4) 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 value at location i o 0(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. Examples: Integert) input (0, null, 2, null, null, 5, 6) KTree tree new KTree> (input, 2) tree.get (0):I/returns 0 tree.get (1): //throw IllegalArgumentException tree.get (6): //returns6

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!