aspose file tools*
The moose likes Java in General and the fly likes Merge Sort in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Merge Sort in Java" Watch "Merge Sort in Java" New topic
Author

Merge Sort in Java

Chandra shekar M
Ranch Hand

Joined: Dec 20, 2006
Posts: 143


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

Joined: Jul 26, 2007
Posts: 157
    
    1

why don't you put result as instance variable, this was you will have state of results.
Chandra shekar M
Ranch Hand

Joined: Dec 20, 2006
Posts: 143
I can make it as a instance variable, But how can i use it in the conquer/merge step.

harshvardhan ojha
Ranch Hand

Joined: Jul 26, 2007
Posts: 157
    
    1

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Merge Sort in Java