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
Following is the partition function for quicksort, where we have used the leftmost number as a pivot. Assume that our array, ARR = {14, 8, 7, 38, 22, 15, 9}, which is 7 in size. What will be the array ARR after we apply "partition(A, 0, 6)"*
9, 15, 22, 38, 7, 8, 14
7, 8, 9, 14, 15, 22, 38
9, 8, 14, 7, 22, 15, 38
9, 8, 7, 14, 22, 15, 38
7, 9, 15, 22, 38, 14, 6
38, 22, 15, 14, 9, 8, 7
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps with 1 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
- Help please. I keep on getting the error color_picker.js:58 Uncaught ReferenceError: colors is not defined at generateColors (color_picker.js:58:25)arrow_forwardGiven the following, write a line of code that will initialize p to point to the “7” inthe array).unsigned char x[] = {2, 3, 5, 7, 11, 13, 17};unsigned char *p, *q; If pointer q in the previous question points to some element of array x, whatexpression will return the index of the element pointed to? E.g., if q points to the 13in the above array, then your expression should return 5 In C Programming Please!arrow_forwardWrite the function divideArray() in script.js that has a single numbers parameter containing an array of integers. The function should divide numbers into two arrays, evenNums for even numbers and oddNums for odd numbers. Then the function should sort the two arrays and output the array values to the console. Ex: The function call: let nums = [4, 2, 9, 1, 8]; divideArray(nums); produces the console output: Even numbers: 2 4 8 Odd numbers: 1 9 The program should output "None" if no even numbers exist or no odd numbers exist. Ex: The function call: let nums = [4, 2, 8]; divideArray(nums); produces the console output: Even numbers: 2 4 8 Odd numbers: None Hints: Use the push() method to add numbers to the evenNums and oddNums arrays. Supply the array sort() method a comparison function for sorting numbers correctly. To test your code in your web browser, call divideArray() from the JavaScript console.arrow_forward
- Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 30, 40}, then newScores = {20, 30, 40, 10}.Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array (int oldScores[4]). See "How to Use zyBooks".Also note: If the submitted code tries to access an invalid array element, such as newScores[9] for a 4-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message. import java.util.Scanner; public class StudentScores { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); final int SCORES_SIZE = 4; int[] oldScores = new int[SCORES_SIZE]; int[] newScores = new int[SCORES_SIZE]; int i; for (i = 0; i < oldScores.length; ++i) { oldScores[i] = scnr.nextInt(); } for (i = 0; i…arrow_forwardWrite a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 30, 40}, then newScores = {20, 30, 40, 10}.Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array (int oldScores[4]). Also note: If the submitted code tries to access an invalid array element, such as newScores[9] for a 4-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message. #include <iostream>using namespace std; int main() { const int SCORES_SIZE = 4; int oldScores[SCORES_SIZE]; int newScores[SCORES_SIZE]; int i; for (i = 0; i < SCORES_SIZE; ++i) { cin >> oldScores[i]; } /* Your solution goes here */ for (i = 0; i < SCORES_SIZE; ++i) { cout << newScores[i] << " "; } cout…arrow_forward' Below you will find code blocks necessary to insert a value into an ordered array given a position (index) to insert. Be careful! Some lines are not needed. 'arrow_forward
- The PARTITION(A) procedure inputs an array A, and takes the fınal element x = A[r] as the pivot element. The output is an array where all elements to the left of x are less than x, and all elements to the right of x are greater than x. An example is provided on pg. 172 of the textbook. In this example, A = [2,8,7,1,3,5,6,4]. The pivot element is x=4 (highlighted in red). The end result of PARTITION is [2,1,3,4,7,5,6,8]. Notice that all elements to the left of 4 are less than 4, and all elements to the right of 4 are greater than 4. I strongly encourage you to go through this example, step by step. Let A = [1,2,7,8,9,6,3,4,5]. Determine PARTITION(A).arrow_forward5. Implement the binary search function below that returns the index of the target value in an integer array. int search(int a[], int t, int l, int r); Given the binary search function in question 5 and the array a below, list all activations when calling search(a, 19, 0 15). -9 -5 -2 0 1 3 7 11 17 19 21 25 27 31 37 41 a index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15arrow_forwardIn the following code both myList and yourList are dynamic arrays of the same size. The code initializes the array myList to certain values. The value in each element of yourList should be twice the value in the corresponding element in myList. However, the output of this code would show that is not the case. Provide the correct code to accomplish the desired results. int *myList;int *yourList;myList = new int[5];myList[0] = 8;for (int i = 1; i < 5; i++)myList[i] = i * myList[i - 1];yourList = myList;for (int i = 0; i < 5; i++)yourList[i] = 2 * myList[i];arrow_forward
- All I know is that we would need to add arr[100] to specify the lengh but I am stuck after thatarrow_forwardNote: Set a random seed of 100 for this assignment. All arrays should contain random numbers between 0 and 1 (zero is inclusive). Create a one-dimensional array of twenty float random numbers. Assign the sum of these values to Q1. Assign the max of these values to Q2. Create a four by five array of random numbers. Take the minimum values in each array and create an array of those values. Assign it to Q3. Assign the mean of all the array values to Q4. Create an array with the following values: 2, 3, np.nan (this should represent a missing value), and 5. Use a numpy function to find the sum of the values in this array. Assign the sum to Q5 (you should expect a numerical value here). Create two separate arrays each containing four random numbers. Concatenate the two arrays and assign it to Q6. Create a four by four array of random numbers and call it q7. Concatenate this array with itself and assign it to Q7. Create a two by four array of…arrow_forwardBelow is how the arrays are represented ARRAY1[] = [1, 5, 6, 6, 9, 9, 9, 11, 11, 21] Here length of ARRAY1 is m. ARRAY2[] = [6, 6, 9, 11, 21, 21, 21] Here length of ARRAY2 is n. Array to be returned would be: ARRAY[] = [6, 9, 11, 21] ATTN : Further, please be reminded that you cannot use library functions to either sort and or perform the de-duplication operation. solve the problem in two ways In a separate implementation, code up a solution in such a way that your solution solves the problem with O(nlog(m)) time complexity 2 or O(mlog(n)) time complexity. Here log means to the base of 2. I’m sure you already know that the hint is to use Binary Search. In the form of sentences, as a comment in your code (at the bottom of your Solution2), you are required to suggest how can Solution2 be improved by leveraging the fact that both the arrays are already sorted. Suggest a solution so that your suggested solution can run linearly with O(m + n) time complexity. Your suggestion should be no…arrow_forward
arrow_back_ios
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