In this lesson we write the merge(arr, low, mid, high) function in C for merge sort. We set up temp[100] and the pointers i, j and k, compare with ≤ to keep the sort stable, copy the leftovers from either half, and copy the result back into arr. An animated trace on 3, 5a, 8 | 5b, 6 shows each line of code at work and shows how equal keys keep their original order. We also explain why temp[100] limits this version to 100 elements. This is part of Unit 3: Searching and Sorting for B Tech 3rd semester students.
Chapters:
00:00 Merge Sort (3/4): merge() in C
00:16 The merge() Function
01:04 Trace: merge(arr, 0, 2, 4)
01:39 Recap: merge() in C
Part of the course: Searching and Sorting – 16 Nov-26 (Lesson 34)
source
