ic static int [] generateRandomArr(int length, int sorted){ } first parameter: an non-negative integer, that specifies the size (length) second parameter: an integer in the range [0, 100], inclusive, that speci ents are sorted. rted%3D0, the contents of the array should be in perfect reverse order. rted%3D100, the contents of the array be 100% sorted. value intermediate should result in an array that has approximately tha : You can approximate this by starting with a perfectly sorted array; t at random (100%- sorted%) of the entries in the array, and override t

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Implement this function in java :
public static int [] generateRandomArr(int length, int sorted){ }
The first parameter: an non-negative integer, that specifies the size (length) of the array that is created.
The second parameter: an integer in the range [0, 100], inclusive, that specifies the degree to which the array's
contents are sorted.
If sorted=0 , the contents of the array should be in perfect reverse order.
If sorted=100, the contents of the array be 100% sorted.
Any value intermediate should result in an array that has approximately that % of its entries that are sorted.
Hint : You can approximate this by starting with a perfectly sorted array;
select at random (100%- sorted%) of the entries in the array, and override those values with a random integer
greater than the value the ordered array's entries. The exception to this is when sorted=100 , in which case the
array's contents must be perfectly sorted.
For example, the following length and sorted parameters might result in the indicated arrays:
1. generateRandomArr(5, 0)
2. generateRandomArr(5, 0)
3. generateRandomArr(5, 100)
4. generateRandomArr(5, 100)
5. generateRandomArr(5, 60)
6. generateRandomArr(5, 20) -
--> [ 34 23 3 2 1]
[6 5 4 3 2]
--> [1 45 52 80 90 ]
-> [1 2 3 4 5]
->[1 24 78 4 5] /l/manipulation of array in no.4
->[ 96 110 123 80 712] //manipulation of array in no.3
Transcribed Image Text:Implement this function in java : public static int [] generateRandomArr(int length, int sorted){ } The first parameter: an non-negative integer, that specifies the size (length) of the array that is created. The second parameter: an integer in the range [0, 100], inclusive, that specifies the degree to which the array's contents are sorted. If sorted=0 , the contents of the array should be in perfect reverse order. If sorted=100, the contents of the array be 100% sorted. Any value intermediate should result in an array that has approximately that % of its entries that are sorted. Hint : You can approximate this by starting with a perfectly sorted array; select at random (100%- sorted%) of the entries in the array, and override those values with a random integer greater than the value the ordered array's entries. The exception to this is when sorted=100 , in which case the array's contents must be perfectly sorted. For example, the following length and sorted parameters might result in the indicated arrays: 1. generateRandomArr(5, 0) 2. generateRandomArr(5, 0) 3. generateRandomArr(5, 100) 4. generateRandomArr(5, 100) 5. generateRandomArr(5, 60) 6. generateRandomArr(5, 20) - --> [ 34 23 3 2 1] [6 5 4 3 2] --> [1 45 52 80 90 ] -> [1 2 3 4 5] ->[1 24 78 4 5] /l/manipulation of array in no.4 ->[ 96 110 123 80 712] //manipulation of array in no.3
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Array
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education