OpenAI's new ChatGPT explains the worst-case time complexity of the bubble sort algorithm, with Python code examples, in the style of a fast-talkin' wise guy from a 1940's gangster movie:

Dec 1, 2022 · 1:39 AM UTC

Replying to @goodside
This thing is pretty impressive. But can also make silly mistakes
In general, you shouldn't expect it to be able to perform accurate calculations, at least not "in its head" — this is a known limitation of models like GPT-3. It only stands a chance if prompted to write calculations out step-by-step like one might do on paper.
Replying to @goodside
I like how the comments in the python code are *not* in 1940s gangster style. Guess that would be a little too far out of distribution
You can sort of watch the code stylistically contaminating its speech — it starts with a comment that contains “ain’t”, but the convention for comments to have formal (or at least modern) style wins out once the actual code appears.
Replying to @goodside
How come this happens?
Tokenization. It doesn’t see text as sequences of characters, but of variable-length tokens about 4 chars on average. It generally can’t do anything that needs to be done one letter at a time. It’s also bad at counting in its head.
Replying to @goodside
But this *isn’t* the worst case! the unsorted list that it starts with should’ve been [8, 5, 4, 2, 1] I wouldn’t expect it to be able to do that… because it’s missing understanding Still astonishing! Take-home exams may be disappearing— Education forever changed!
Oh, so we got a wise guy, huh?
Replying to @goodside @punk6529
That's incredible!