Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the second is the HW06.java For this homework the code skeleton is provided for you in HW06.java file. There are three methods to be implemented,

the second is the HW06.java image text in transcribed
image text in transcribed
For this homework the code skeleton is provided for you in HW06.java file. There are three methods to be implemented, described in the following static void recursiveBubbleSortint arr) //sorts an array using bubble sort in a recursive manner. Hint: do one pass(which puts the biggest element at the end) then recur (25 points) static String reverseString(String input)//reverses a string in a recursive manner. returns the reversed string. You can use charAt0 and substring0 methods. (25 points) static int getKthLargest (int[] arr, int k) finds the Kth largest item in an unsorted array arrl]. Note that you are not allowed to sort the array and return the kth element. The idea is to call the partition method of quicksort, and compare the returned index with k. Based on the comparison, you can decide which subarray to continue searching (similar to binary search), or return if you have found the kth largest item. The code for partitioning is provided in the code skeleton. (50 points) Submission Instruction: Complete the HW06.java file and submit it to the Blackboard. Write your code in the specified sections. Do not rename methods or change method signatures. You may add other methods (or overload methods) if you want. Only submit the java file, no doc or archive files. ile 7:32 HW06.java import java.util.Arrays public class HNO6 /sorts an array using bubble sort in a recursive static void recursiveBubblesort(int arr) //implement this //reveres a string in a recursive manner static String reversestring(String input) /linplement this //finds the Kth largest item in an unsorted array arr, without sorting it public static int getKthLargest(int arr, int //implement this public static int partition(int arrl,int low, int high) int pivot arrhigh]: int i- (low-1): index determining the end of left partition for (int j-low: Jchigh: j++) if (arrl31pivot) arrlj] should be in the left partition /I swap arri and arr15 int temp arr arri-arr arrtemp // put the pivot in its place int temp arrti+l: arrti+i1 arr[high]: return i1i public static void main(Stringt1 args) intl arr- (1,5,2,4,10,10,66) System.out-printin(getkthLargest (arr,1)) recursiveBubbleSort(arr) System.out.println(Arrays.tostring(arr)) System.out.printin(reverseString( abc)

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

Students also viewed these Databases questions