Question: //IN JAVA, COMPLETE THE FOLLOWING METHODS //CREATE A K-ARY TREE //MAY NOT IMPORT ANYTHING ELSE import java.util.Iterator; import java.util.Scanner; import java.io.File; import java.io.IOException; import java.util.ArrayDeque;

//IN JAVA, COMPLETE THE FOLLOWING METHODS

//CREATE A K-ARY TREE

//MAY NOT IMPORT ANYTHING ELSE

import java.util.Iterator; import java.util.Scanner; import java.io.File; import java.io.IOException; import java.util.ArrayDeque;

public class KTree implements TreeIterable { public KTree (E[] arrayTree, int k) { //constructs a k-ary tree, arrayTree stores the tree in level order with the root at index 0 //the branching factor is k //must copy elements from the array to your internal storage //may use array-based or link-based representaions } public int getK() { //returns k value of tree return 0; } public int size() { //returns number of elements return 0; } public int height() { //returns the heihgt of the tree return 0; } public E get(int i) { //returns value at location i (tree is in level-order) return null; } public boolean set( int i, E value) { //Given a value, place the node at location i //replace any node's value at location i //if value is null, this method acts as a remove method return true; } public Object[] toArray() { //returns a copy of the tree stored in level-order //You must copy the elements from your internal storage to a new array, do not just //return your internal storage if you are using an array-based representation. return null; } }

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!