Skip to main content
Commonmark migration
Source Link

SmileBASIC, 79 bytes

DEF S A
FOR Z=0TO I
FOR I=1TO LEN(A)-1SWAP A[I-(A[I-1]>A[I])],A[I]NEXT
NEXT
END

#SmileBASIC, 79 bytes DEF S A FOR Z=0TO I FOR I=1TO LEN(A)-1SWAP A[I-(A[I-1]>A[I])],A[I]NEXT NEXT END It'sIt's bubble sort but instead of checking to see if it's finished, it just assumes that every input is the worst case and does n^2 (actually n*(n+2)) iterations.

#SmileBASIC, 79 bytes DEF S A FOR Z=0TO I FOR I=1TO LEN(A)-1SWAP A[I-(A[I-1]>A[I])],A[I]NEXT NEXT END It's bubble sort but instead of checking to see if it's finished, it just assumes that every input is the worst case and does n^2 (actually n*(n+2)) iterations.

SmileBASIC, 79 bytes

DEF S A
FOR Z=0TO I
FOR I=1TO LEN(A)-1SWAP A[I-(A[I-1]>A[I])],A[I]NEXT
NEXT
END

It's bubble sort but instead of checking to see if it's finished, it just assumes that every input is the worst case and does n^2 (actually n*(n+2)) iterations.

added 43 characters in body
Source Link
12Me21
  • 6.7k
  • 1
  • 22
  • 40

#SmileBASIC, 79 bytes DEF S A FOR Z=0TO I FOR I=1TO LEN(A)-1SWAP A[I-(A[I-1]>A[I])],A[I]NEXT NEXT END It's bubble sort but instead of checking to see if it's finished, it just assumes that every input is the worst case and does n^2 (actually n*(n+2)) iterations.

#SmileBASIC, 79 bytes DEF S A FOR Z=0TO I FOR I=1TO LEN(A)-1SWAP A[I-(A[I-1]>A[I])],A[I]NEXT NEXT END It's bubble sort but instead of checking to see if it's finished, it just assumes that every input is the worst case.

#SmileBASIC, 79 bytes DEF S A FOR Z=0TO I FOR I=1TO LEN(A)-1SWAP A[I-(A[I-1]>A[I])],A[I]NEXT NEXT END It's bubble sort but instead of checking to see if it's finished, it just assumes that every input is the worst case and does n^2 (actually n*(n+2)) iterations.

added 119 characters in body
Source Link
12Me21
  • 6.7k
  • 1
  • 22
  • 40

#SmileBASIC, 79 bytes DEF S A FOR Z=0TO I FOR I=1TO LEN(A)-1SWAP A[I-(A[I-1]>A[I])],A[I]NEXT NEXT END It's bubble sort but instead of checking to see if it's finished, it just assumes that every input is the worst case.

#SmileBASIC, 79 bytes DEF S A FOR Z=0TO I FOR I=1TO LEN(A)-1SWAP A[I-(A[I-1]>A[I])],A[I]NEXT NEXT END

#SmileBASIC, 79 bytes DEF S A FOR Z=0TO I FOR I=1TO LEN(A)-1SWAP A[I-(A[I-1]>A[I])],A[I]NEXT NEXT END It's bubble sort but instead of checking to see if it's finished, it just assumes that every input is the worst case.

Source Link
12Me21
  • 6.7k
  • 1
  • 22
  • 40
Loading