Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//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 {

//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

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

Step: 3

blur-text-image

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

What Is A Database And How Do I Use It

Authors: Matt Anniss

1st Edition

1622750799, 978-1622750795

More Books

Students also viewed these Databases questions

Question

Define the term Working Capital Gap.

Answered: 1 week ago