Urgent One Hour Java Define Method Named Sortarray Sort One Dimensional Array Integers May Q37274379

URGENT in one hour. JAVA:

Define a method named SortArray() to sort a one dimensionalarray of integers. YOU MAY NOT CALL A BUILT-IN SORTING FUNCTION,but should write your own.

The method should return the sorted array. You may use whicheversorting algorithm you prefer, in order to sort the array.

Please initialize an array and fill it with random values beforebeginning. Ensure that it has a size of at least 10.


Answer


CODE

// Java program for implementation of Bubble Sort

public class BubbleSort

{

int[] SortArray(int arr[])

{

int n = arr.length;

for (int i = 0; i < n-1; i++)

for (int j = 0; j < n-i-1; j++)

if (arr[j]

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.