Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I want to define an array and sort it in ascending order (without using arrays.s

ID: 3650590 • Letter: I

Question

I want to define an array and sort it in ascending order (without using arrays.sort function) can someone help me ?

Thanks.

I defined a function which is asking array is sorted or not=

int []x=new int[2];
int [] arrayer(int[] a){
for(int i=0;i<a.length;i++)
{ a[i]=(int)random(400); }
return a;
}

boolean issorted (int [] y) {boolean r=true;
if(y.length<=1)
return true;
for(int i=0; i<y.length-1; i=i+1)
{if(y[i]>y[i+1])
return false;
}return r;}




void setup(){
print( issorted(arrayer(x)));
}

Explanation / Answer

public class bubbleSort{ public static void main(String a[]){ int i; int array[] = {12,9,4,99,120,1,3,10}; System.out.println("Values Before the sort: "); for(i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote