reduced complexity of bubble sort