Jump to content

Sorting algorithms/Bubble sort: Difference between revisions

m
Prevent out of bounds errors for empty and 1 item lists.
m (Prevent out of bounds errors for empty and 1 item lists.)
Line 17:
This can be expressed in pseudo-code as follows (assuming 1-based indexing):
'''repeat'''
'''if''' itemCount <= 1
'''return'''
hasChanged := false
'''decrement''' itemCount
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.