AI engineering glossary · Data structures algorithms

What is merge sort?

Merge sort: A divide and conquer sorting method that splits the list in half, sorts each half recursively and then merges the two sorted halves. It runs in O(n log n) time in every case, is stable and needs O(n) extra memory.

Level: intermediateTopic: Data structures algorithms

Merge sort: an example

Sorting [8, 3, 5, 1]: split into [8, 3] and [5, 1], sort each to [3, 8] and [1, 5], then merge to [1, 3, 5, 8].

Related terms

More Data structures algorithms terms

Where you learn it

Merge sort is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.