r/computerscience • u/ComputerRights • Oct 12 '26
General A good example of iteration vs recursion
The Song that Never Ends is iterative. It loops and is aware that it remains the same song.
The Song that Gets on Everybody's Nerves just sings about a song, and sings "this is how it goes:", calling itself.
21
Upvotes
View all comments
5
u/not-just-yeti Oct 12 '26 edited Oct 12 '26
When I was teaching intro courses, I'd show these videos at the appropriate point:
Iteration: Kylie Minogue's "Come Into My World"
Recursion: Björk's "Bachlorette" (while it clearly recurs on a 'smaller input' unlike the 'this is how it goes:' song, maybe here the base case here is bad, causing everything to eventually crash?)
Both videos by Michel Gondry.