
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Implement the following method in Java:
public static void shuffle(Object[] obj){}
It shuffles an array in nlog(n) time using recursion. You must not use helper methods or change parameters.
Assume calls to the Random library happen in constant time. It should be possible for any element to re-position to any other position.
After completion, explain why your
Hint: Think about merge sort.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Java Write a method to return the first duplicated string in an array. Comparison must check case (e.g., red != Red). Hint: To identify duplications in the array, you need to compare elements in pairs. How should you compare elements in a 1D array? Note: You only need to write down the code inside the myMethod() code block public class CST1201Test3 { public static void main(String[] args) { int[] myNumbers = {"blue", "red", "Blue", "yellow", "red", "green"}; System.out.println(myMethod(myNumbers)); } static int myMethod(int[] numbers) { // your answer } }arrow_forward44 // create a loop that reads in the next int from the scanner to the intList 45 46 47 // call the ReverseArray function 48 49 50 System.out.print("Your output is: "); 51 // print the output from ReverseArray 52 ww 53 54 55 }arrow_forwardWhat is the process to create an explicit bigO calculator for selection sort, insertion sort merge sort, and quicksort? Java. AP Computer Science A. One class. There is supposed to be four original lists, which is a random list of numbers from 1-10 with 10 items, these lists will be used by the four sorts. There should be the sorted list for those original lists from each sort method. There should be an amount of comparisons for each sort. Also there should be bigO information, the best case, average case, worst case, the nlog2n, the n^2, sorting 10 lists from the sort methods of n increasing. Thank you. What the output can look like:arrow_forward
- Write a version of the bubble sort algorithm that sorts a list of integers in descending order. Namely, change the bubble sort method to sort the parameter array in descending order. Hint: Bubble sort: void bubbleSort(int array(1) { int size = array.length; boolean isChanged = false; for (int i = 0; i < size - 1; i++) isChanged = false; for (int j = 0; j < size . 1 . 1; j++) if (array(s) > array() + 1]) { int temp = array(s); array[3] . arrays + 1); array() + 1] = temp; is Changed = true; } if (isChanged) break;arrow_forwardRefer to the ArrayCollection.java) in your Canvas Modules. If N represents the number of elements in an ArrayCollection, then the add method in that collection instance is of which of the following efficiency? O O(N) O(log N) O(1) O None of the choices O(N log N)arrow_forwardTask - 2: Write a java program (AnyTypeMergeSort.java) to implement the Merge Sort algorithm to sort the array containing any type of elements (suppose strings). Your program will have the following method signature: ● ● public void mergeSort(T[] A, int lowerBound, int upperBound) public void merge(T[] A, int lowerBound, int midPoint, int upperBound) Following is the Merge Sort Algorithm MERGE-SORT (A, p,r) 1 if p≥r 2 3 4 5 6 // Merge A[p:q] and A[q + 1:r] into A[p:r]. 7 MERGE(A, p, q, r) 4 Where p and r represent lower (starting index) and upper (ending index) bounds of array A respectively. The Merge Sort calls the following Merge Algorithm that accepts q as the mid of the array along with p and r: MERGE(A, p, q, r) 1 n₂ = q-p+1 2 nR=r-9 3 let L[0:n 5 6 7 8 9 10 11 return ANZEIGEN q = [(p+r)/2] MERGE-SORT(A, p, q) MERGE-SORT (A, q + 1,r) 22 25 26 27 i = 0 j = 0 k = p 12 13 14 15 16 17 18 19 // Having gone through one of L and R entirely, copy the // remainder of the other to the end…arrow_forward
- in javaarrow_forwardmake the array an arraylist instead and include the file you usedarrow_forwardUsing JAVA, write a method that swaps two rows of a two-dimensional array. The row indices to be swapped are passed as parameters to the method (Assume row indices are valid indices). Write a test program to demonstrate correct operation of the method.arrow_forward
- A. Can you draw the animation of Merge sort: given an unsorted array of size 10, show the divide andconquer techniqueb. What is Running time for Merge Sort: O(nlogn) such that n is the size of thearray: Reference code attachedarrow_forwardwrite a java program that implements the selection sort algorithum that sorts list of doubles in the range of [0,500). use array objects that use to contain the listarrow_forwardMergesort is a method that takes an integer array and returns a sorted copy of the same array. It first sorts the left half of the input array, then the right half of the input array, and finally merges the two sorted halves together into a sorted version of the input array. Implement the mergesort method public static int[] mergesort(int[] arr) { return new int[] {-1}; } *must be in this layout and done in javaarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education