Merge sort Java
I'm trying to create a merge sort method, but it continues to give the wrong sort Where do I make changes to actually sort the array? Which part of the code must be different? Thank you for your time
Editor: now mergesort doesn't really sort numbers. Can someone tell me what it is? Especially when I print the "test merge sort" section
Solution
First of all, I assume this is academic rather than practical, because you don't use the built-in sorting function Having said that, here are some things to help you move in the right direction:
In general, merge sort can be regarded as two different methods: merge() function merges two sort lists into one sort list, and mergesort() recursively splits the list into a single element list Because a single element list has been sorted, you combine all the lists into a large sorted list
These are some deputy pseudocodes:
Maybe it will help clean up where you want to go
If not, Wikipedia will always have mergesort
Additional:
To help you, here are some comments inline with your code
I'm deliberately vague, so think about the algorithm Try inserting your own comments into the code If you can write about what happened conceptually, you may not need stack overflow
The above is all the content of merge and sort Java collected and sorted by programming house. I hope this article can help you solve the program development problems encountered by merge and sort Java.
If you think the content of the programming home website is good, you are welcome to recommend the programming home website to programmers and friends.