1. Find the maximum, minimum, and average values of an array element
2. Copying and inversion of arrays
Scenario 1:
Scenario 2: (How to implement Replication)
Inverse of the array:
Inverse of an array element
for (int i = 0;i < arr.length/2;i++) {
int temp = Arr[i];
Arr[i] = arr[arr.length-1-i];
Arr[arr.length-1-I] = temp;
// }
for (int x = 0, y = arr.length-1; x < y; + x, y--) {
int temp = arr[x];
ARR[X] = Arr[y];
Arr[y] = temp;
}
Extension: String str = "ABCDEFG";
Sort the array:
Insert Sort
Direct Insert Sort, binary insert sort, shell sort
Exchange sort
Bubble sort, quick sort (or partition exchange sort)
Select sort
Simple select sort, heap sort
Merge sort
Base sort
//Use bubble sort to arrange array elements from small to large
//for (int i = 0; i < arr.length-1; i++) {
//for (int j = 0; J < arr.length-1-I; j + +) {
//if (Arr[j] > arr[j + 1]) {
//int temp = arr[j];
//arr[j] = arr[j + 1];
//arr[j + 1] = temp;
//}
//}
//}
////array elements from small to large using the direct selection sort
//for (int i = 0; i < arr.length-1; i++) {
//int t = i;//default i is the smallest
//for (Int j = I;j < arr.length;j++) {
////Once after I find that there is a smaller element than that, record the lower corner of the element
//if (Arr[t] > Arr[j]) {
//t = j;
//}
//}
//if (t! = i) {
//int temp = arr[t];
//arr[t] = arr[i];
//arr[i] = temp;
//}
//}
You can also call: Arrays Tool class: Arrays.sort (arr);
Common algorithm problems for arrays