# Problem 4. 20 Sort with Memory]Input: An unsorted array of numbers, AOutput: Two arrays [B, P. B is an ascending sorted array containing the elements of A and P is anarray such that P(i) k, if the element in position i of B was in position k in A (i.e. B[i] A[k])=Example Input: [4, 2, 1]Example Output: B,P [1,2,4], [3,2,1]]Hint: Consider a simple modification of Merge Sort

Question
57 views help_outlineImage TranscriptioncloseProblem 4. 20 Sort with Memory] Input: An unsorted array of numbers, A Output: Two arrays [B, P. B is an ascending sorted array containing the elements of A and P is an array such that P(i) k, if the element in position i of B was in position k in A (i.e. B[i] A[k]) = Example Input: [4, 2, 1] Example Output: B,P [1,2,4], [3,2,1]] Hint: Consider a simple modification of Merge Sort fullscreen
check_circle

Step 1
• Create java class “PositionInArray” and create a required method to perform sorting by merge sort.
• Create method “merge_arr” and “sort_element” to perform sorting in “sort_element” method divide array into half recursively and at the end call method “merge_arr” to sort and merge...

### Want to see the full answer?

See Solution

#### Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

### Programing 