Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3484398
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:47:02+00:00 2026-05-18T10:47:02+00:00

http://pt.wikipedia.org/wiki/Merge_sort#Java That code does not compile. Thank you.

  • 0

http://pt.wikipedia.org/wiki/Merge_sort#Java
That code does not compile.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:47:02+00:00Added an answer on May 18, 2026 at 10:47 am

    Here’s a working implementation from http://rosettacode.org/wiki/Merge_sort#Java, linked to from the English Wikipedia article on merge sort.

    import java.util.LinkedList;  
    public class Merge<E extends Comparable<? super E>> {  
        public LinkedList<E> mergeSort(LinkedList<E> m){  
            if(m.size() <= 1) return m;  
    
            int middle= m.size() / 2;  
            LinkedList<E> left= new LinkedList<E>();  
            for(int i= 0;i < middle;i++) left.add(m.get(i));  
            LinkedList<E> right= new LinkedList<E>();  
            for(int i= middle;i < m.size();i++) right.add(m.get(i));  
    
            right= mergeSort(right);  
            left= mergeSort(left);  
            LinkedList<E> result= merge(left, right);  
    
            return result;  
        }  
    
        public LinkedList<E> merge(LinkedList<E> left, LinkedList<E> right){  
            LinkedList<E> result= new LinkedList<E>();  
    
            while(!left.isEmpty() && !right.isEmpty()){  
                //change the direction of this comparison to change the direction of the sort  
                if(left.peek().compareTo(right.peek()) <= 0) result.add(left.remove());  
                else result.add(right.remove());  
            }  
    
            result.addAll(left);  
            result.addAll(right);  
            return result;  
        }  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization Is this design pattern possible in Java? If so, how? If not, why
http://en.wikipedia.org/wiki/Zephyr_(protocol) Does there exist a Java library or some sort of Java implementation of
// Refer: http://en.wikipedia.org/wiki/Decimal I have a snippet like this in my java source code,
I have read the explanation in http://en.wikipedia.org/wiki/PageRank and i understand that the page rank
I want to implement a version of Benford's law ( http://en.wikipedia.org/wiki/Benford%27s_law ) that basically
http://en.wikipedia.org/wiki/All_nearest_smaller_values . This is the site of the problem and here is my code,
I saw in the wiki page http://en.wikipedia.org/wiki/Comparison_of_regular_expression_engines that python use non-recursive implementation as grep
From this Wikipedia article: http://en.wikipedia.org/wiki/Hamiltonian_path_problem A randomized algorithm for Hamiltonian path that is fast
[ is not classed a unicode character http://en.wikipedia.org/wiki/List_of_Unicode_characters (my guess) as to why this
http://en.wikipedia.org/wiki/Server_Side_Includes For dynamic contents, I don't see any benefit of SSI,is that the case?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.