Merge Sort Split and Merge
Step by Step
Every array splits in half until one number is left, then sorted pieces merge by taking the smaller front.
Step through every split and merge in both directions, then share a link to the step where the order went wrong.
What You Watch While Pieces Merge
Splits, comparisons and merges all show up on screen.
Merge sort does its real work while merging, when two sorted pieces become one.
CodeStory's visualiser shows every split, comparison and merge, pass by pass. Highlighted code lines follow along, and you can step back, step forward or play.
Try your own array with duplicates, then watch how the two pieces merge.
How Merge Sort Splits and Merges
Steps below follow the pieces on your screen.
- 1Split the array in half.
- 2Keep splitting every piece until only one number is left.
- 3Compare the front numbers of two sorted pieces.
- 4Move the smaller front number into the merged piece.
- 5Keep merging until one sorted array remains.
Merge Sort Cost in Time and Space
Interviewers ask why merge sort needs extra memory, and the visualiser counts real operations.
- Time
- O(n log n)counted from the comparisons and merges you step through
- Space
- O(n)extra memory to hold merged pieces
- Pattern
- SortingOrder grows one comparison at a time.
Practise Sorting Beyond Merge Sort
Watching shows the merges and solving trains you to code them.
Everything in the App in One Place
Practice, interviews and tools all start free. Swipe to see the rest.
DSA practice
Problems filed under the pattern that solves them, not a sheet.
352 problemsOpenCompany sets
Practise what one company asks in the week before your round.
463 companiesOpenCoding interview
Choose a role, write in a real editor and answer while you type.
scored reportOpenMock interviews, spoken
You answer out loud and CodeStory follows up on what you said.
32 topicsOpenDatabase round
Answer DBMS the way a panel asks it, with indexes, joins and normal forms.
in Core CSOpenOOP round
Inheritance, polymorphism and the follow-up you never rehearse.
in Core CSOpenSystem design
How real systems are built, from the primitives to the AI stack.
27 chaptersOpenSQL practice
Real schemas, your query, the rows it returns and a clear verdict.
39 questionsOpenAptitude
Quant, logical, verbal, DI and technical, timed like the real test.
280 questionsOpenOnline assessment
Get a clock, marks per question and hidden tests like a company's judge.
37 papersOpenAlgorithm visualiser
Watch it play on your own input, one step at a time.
26 algorithmsOpenAI that helps, not solves
Hints one at a time and AI review before a mentor sees your work.
100 free creditsOpenResume builder
Build it inside the app, next to the work you practised.
in the appOpenProgress and readiness
One score and the axis where you are weakest.
tracked dailyOpen
Sign up for 100 AI credits now and get 100 more every month. Start free in the app
Merge Sort Visualiser FAQs
Open the visualiser and follow the pieces as they merge.
Open the visualiserWhat does the merge sort visualiser show?
CodeStory's visualiser shows every split, comparison and merge on an array you choose, with the highlighted line of code beside it. Use the controls to go back, go forward or let it play.
What is the time complexity of merge sort?
O(n log n) time and O(n) space in every case. CodeStory's visualiser counts real operations while it plays, so the number grows where you can see it.
How does merge sort work?
Merge sort splits the array in half until single numbers remain, then merges sorted pieces by taking the smaller front number every time.
Why is merge sort faster than bubble sort?
Merge sort takes O(n log n) time while bubble sort takes O(n²). Open both visualisers on the same array to compare the number of comparisons.
Can I use my own input?
Yes. Enter your own array and the visualiser splits and merges it step by step.
Is the visualiser free?
Yes. Sign up for 100 AI credits, collect 100 more every month and watch any algorithm with no credits spent.
Stuck on Sorting? Get a Free Callback
Tell CodeStory which sorting step loses you, and a mentor plans what comes next.
- 1CodeStory checks your level, from sorting basics to interview ready.
- 2CodeStory explains online and campus batches, with timings that fit your routine.
- 3You decide. No pressure, no payment on the call.