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 7915845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:35:45+00:00 2026-06-03T14:35:45+00:00

I need to sort arrays of varying sizes. These sizes are: 10 elements, 50

  • 0

I need to sort arrays of varying sizes. These sizes are: 10 elements, 50 elements, 100 elements, 500 elements, and 1000 elements. For each of these array sizes, I should use one array that is already sorted, another array that is partially sorted, and one that is random. I should use three sorts, like quicksort, insertion, or bubblesort. I have been working this for 2 weeks but can not seem to create an call the arrays.

  • 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-06-03T14:35:48+00:00Added an answer on June 3, 2026 at 2:35 pm

    Here are some utility methods to create test arrays and to verify if your sorting method is working fine:

    public static Integer[] createRandomArray(int size) {
        Integer[] result = new Integer[size];
        Random randomGenerator = new Random();
        for(int i = 0; i < size; i++) {
            result[i] = randomGenerator.nextInt(size*100);
        }
        return result;
    }
    
    public static Integer[] createSortedArray(int size) {
        return createPartiallySortedArray(size, 0, size);
    }
    
    public static Integer[] createPartiallySortedArray(int size, int from, int to) {
        Integer[] result = createRandomArray(size);
        Arrays.sort(result, from, to);
        return result;
    }
    
    public static boolean isSorted(Integer[] original, Integer[] sorted) {
        Integer[] clonedOriginal = Arrays.copyOf(original, original.length);
        Arrays.sort(clonedOriginal);
        return Arrays.equals(clonedOriginal, sorted);
    }
    

    Note – the from and to parameters have to be in the range [0..size-1] with from < to.


    Here’s fragment that you can use to create your arrays, feed them into your sorter and verify the results:

    public static void main(String[] args) {
        List<Integer[]> arrays = new ArrayList<Integer[]>();
        int size = 100;
        arrays.add(createRandomArray(size));
        arrays.add(createPartiallySortedArray(size, 0, size/2));
        arrays.add(createSortedArray(size));
    
        List<Integer[]> result = doBubbleSort(arrays);  // <- implement that method
        for (int i = 0; i < arrays.size(); i++)
            System.out.println(isSorted(arrays.get(i), result.get(i)));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to sort arrays inside an array of array based on one of
I have an array which i need to sort its elements by occurrence then
hello guys i need to sort some elements of integer in an integer array
I need to sort 20+ arrays, already on the GPU, each of the same
I found that java.util.Arrays.sort(Object[]) use 2 kinds of sorting algorithms(in JDK 1.6). pseudocode: if(array.length<7)
I need to sort an array containing arrays in ascending numerical order. The data
I need to sort an array of ActiveRecord objects by the value in one
I have the following arrays: http://jsfiddle.net/3NZsK/ I need to sort the arrays by their
I need to sort an array that can look like this: $array[4][0] = array('id'
I need to sort an array of months (alphabetical months) according to their months

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.