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
Asked Oct 26, 2019
57 views

Please use Java

Problem 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
help_outline

Image Transcriptionclose

Problem 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

Expert Answer

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

Check out a sample Q&A here.

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

Engineering

Computer Engineering

Programing

Related Computer Engineering Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: What are some comparison and differences between Google Spreadsheets and Excel?

A: Comparison of Google spreadsheet and Excel:They are the computer applications that allow the user to...

question_answer

Q: Use the Java Class, Account.java, provided. Please do not rename or make any changes to this class. ...

A: Program DescriptionTwo java files rinoel_Bank.java and rinoel_testBank.java contain the correspondin...

question_answer

Q: What is system change-over

A: System changeover is a process of changing the way a thing is done to another and how other activiti...

question_answer

Q: Why is binary search algorithm better than sequential search?

A: Sequential search algorithm involves visiting each and every element of the list of elements and see...

question_answer

Q: What are REST web services and what is the reason for its popularity?

A: REST stands for Representational State Transfer and is an architectural style for most web based app...

question_answer

Q: 1.1 Show that the following sets satisfy the law of contradiction and law ofexcluded middle.X = {a, ...

A: The conditions for to satisfy the law of contradiction and the law of excluded middle are:

question_answer

Q: What could be the value of the register Stl after executing the instruction SLL $t1, $t0, 1 if the v...

A: A Shift left logical (SLL) of one position moves each bit to the left by one.After executing the giv...

question_answer

Q: Based on a decision tree structure - what are three decisions that may be applicable to a project? w...

A: A decision tree is a supervised learning technique which acts as a decision support tool. It forms a...

question_answer

Q: How to do pseudocode, flowchart and c language to calculate the volume of sphere?

A: Pseudocode:Declare the variable to store the value of radius.Declare the variable to store the volum...