# 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](https://www.ask-codey.com/glossary?category=software-development&level=2)

Updated: November 9, 2026

## In other subjects

- [Nested Loop in C#](https://www.ask-codey.com/glossary/nested-loop-c-sharp)
- [Nested Loop in Java](https://www.ask-codey.com/glossary/nested-loop-java)
- [Nested Loop in JavaScript](https://www.ask-codey.com/glossary/nested-loop-javascript)
- [Nested Loop in Python](https://www.ask-codey.com/glossary/nested-loop)

Source: https://www.ask-codey.com/glossary/nested-loop-software-development
