Compare
Swap
Unsorted
Sorted
Enhance with AI
Pseudocode
numberOfPasses = arrayValues.length - 1
firstIndex = 0
currentIndex = 0
currentSmallestValue = 0
WHILE numberOfPasses > 0:
currentSmallestValue = arrayValues[currentIndex]
WHILE currentIndex < arrayValues.length - 1:
IF currentSmallestValue > arrayValues[currentIndex + 1]:
currentSmallestValue = arrayValues[currentIndex + 1]
END IF
currentIndex = currentIndex + 1
END WHILE
IF arrayValues[firstIndex] ≠ currentSmallestValue:
SWAP arrayValues[firstIndex], arrayValues[indexOfCurrentSmallestValue]
END IF
firstIndex = firstIndex + 1
currentIndex = firstIndex
numberOfPasses = numberOfPasses - 1
END WHILE
PLAY
PAUSE
RESET
SLOWFAST
AI Assistant
Responsible AI use: AI-generated responses may occasionally contain inaccurate information.
Please review its responses critically and do not share personal or sensitive information.