Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will implement a Minimum Oriented 3 - Heap data structure for String values ( MinString 3 Heap ) . 3 - Heap is a

You will implement a Minimum Oriented 3-Heap data structure for String values (MinString3Heap).3-Heap is a data structure where each node can have a maximum of 3 children. Other than that, the min-heap rules apply: Parent node is smaller than its children. An example of a Min-3Heap is given below: Figure 1- An example of a Minimum Oriented 3-Heap for String values and how its kept on array. TASKSCopy the following java code as the starting template for your MinString3Heap implementation. public class MinString3Heap { private String[] values; private int N =0;public MinString3Heap(){ this.values = new String[20]; }public void insert( String value ){// You will implement this method// Method takes a String and inserts into the 3-Heap}private void swimRecursive( int index ){// You will implement this method // Method takes an item index andpublic String removeMin(){// You will implement this method // Method removes and returns theRECURSIVELY!swims the item up in the treeminimum element from the tree}}private void sinkRecursive( int index ){// You will implement this method // Method takes an item index andpublic void delete( int index ){// You will implement this method // Method takes an item index and}RECURSIVELY!sinks the item down in the treeremoves the item from the tree}public void update( int index, String newValue ){// You will implement this method// Method takes an item index, a String and updates the items value }public void print(){for (int i=1,_N=N; i<=_N; i++){System.out.println( removeMin()); }}} The MinString3Heap holds at most 20 String values in an array and keeps the array as a Complete Tree. You will implement the methods explained in the code following the Heap rules and keeping each method in O(logN) time complexity.TESTINGThe print method for the heap is already given for you in the template. Test your implementation with the given Main method below in a Main.java file, where you can also add/remove/change strings to test with different inputs. public static void main(String[] args){ MinString3Heap heap = new MinString3Heap(); heap.insert("Kemal"); heap.insert("Zerrin"); heap.insert("Ahmet"); heap.insert("Beril"); heap.insert("Canan"); heap.insert("Hikmet"); heap.insert("Okan"); heap.update(2, "Mehmet"); heap.update(4, "Fatih"); heap.delete(2); heap.print(); // should print : // Ahmet }// Fatih// Kemal// Mehmet// Okan// Zerrin

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

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

rnctee

Answered: 1 week ago