Nested Loop
noun
say it: “NES-tid LOOP” /ˈnɛstɪd luːp/
A loop placed inside another loop, so the inner one runs all the way through for every pass of the outer one.
What is a nested loop?
A nested loop is a loop inside another loop. For every pass of the outer loop, the inner loop runs all the way through, like checking every seat in a row before moving on to the next row. When both loops go over the same n items, the inner work runs n × n times, which is why a nested loop is the usual sign of O(n²) work.
In a sentence
- “Checking every song against every other song takes a nested loop, and that's O(n²) work.”
Level: Apprentice · More Software Development terms at this level
Updated