Mergesort in java

后端 未结 12 539
予麋鹿
予麋鹿 2020-12-03 06:09

I am new to Java and have tried to implement mergesort in Java. However, even after running the program several times, instead of the desired sorted output, I am getting the

12条回答
  •  爱一瞬间的悲伤
    2020-12-03 06:10

    The problem is that java is pass by value and not pass by reference... When you are assigning to array A in the merge method you are changing a copy of the reference to A and not the reference to A itself. Therefore you need to pass A into your merge method and make a structural change to A.

提交回复
热议问题