Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Merge Sort in Java

 
Chandra shekar M
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I this code , Divide part works correctly, how do i implement the merge part of it, The conquer method does merge the elements passed for the given iteration, but the state of this should be available for the next iteration how can i do this?

There are solution on the net using some low,mid,high keys i wanted it to be more efficient am m trying in this way. Please suggest ?
 
harshvardhan ojha
Ranch Hand
Posts: 157
1
Android Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why don't you put result as instance variable, this was you will have state of results.
 
Chandra shekar M
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can make it as a instance variable, But how can i use it in the conquer/merge step.

 
harshvardhan ojha
Ranch Hand
Posts: 157
1
Android Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the state of this should be available for the next iteration


If you want to check state of your result for every iteration it needs to be an instance variable. If this is not the solution, probably i misunderstood your problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic