Data Structures, Algorithms, Java, Big O Notation, Searching And Sorting.
int lastIndex = arr.length()-1; for (int i=0; i<lastIndex; i++){ for(int j=0; j<lastIndex-i; j++){ if(arr[j+1] < arr[j]){ int temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } } } } Selection Sort vs Bubble Sort Both have the same time and space complexity, but Selection Sort executes fewer