Answers for "Robin was sorting an array using bubble sort technique realise that no swap was made during the first pass"

3

bubble sort code

func Sort(arr []int) []int {
	for i := 0; i < len(arr)-1; i++ {
		for j := 0; j < len(arr)-i-1; j++ {
			if arr[j] > arr[j+1] {
				temp := arr[j]
				arr[j] = arr[j+1]
				arr[j+1] = temp
			}
		}
	}
	return arr
}
Posted by: Guest on August-16-2020

Code answers related to "Robin was sorting an array using bubble sort technique realise that no swap was made during the first pass"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language