Merge Sort -

2 mins 51 sec read Basic

What is merge sort ?

Merge sort is divide and conquer sorting algorithm . Merge procedure is the heart of algorithm. Given two sorted arrays of size M & N, merge procedure will create a new sorted array of size M + N.

How Merge Sort works ?

Consider an array of 5 elements (2,5,4,1,3) . Merge sort can be visualised in three phases :

1) Divide.

2) Conquer.

3) Combine.

1) In the given example, the given array is split into two smaller arrays. Now, these two smaller arrays will recursively split themselves further into smaller arrays till only one element is left in an array. This phase is called as Divide Phase. In the given diagram, as you can see on the fourth step, each element is split in its own individual array.

2) Now in Conquer Phase merge procedure will combine these arrays in ascending order.

3) Now in Combined Phase these smaller sorted arrays will merge together to form a single sorted array of original size.

How was the tutorial? Nice. Right?

Deep Concept videos to crack the highly-piad interviews.

Chekout out our Youtube Channel to get detailed video content on important topics in interviews.

What is your Interview Score?

Test your skillset with the curated questions created by experts around the globe.

Book a free test slot. Now !.

It usually takes 30 mins for an online test and this test will be MCQ based. Get detailed analytics based on your test and recommedations with personalised roadmaps.

Book a test slot. Now!

Have questions about the trial coding class?

Chat with our experts to discuss

Connect on WhatsApp

Recommended tutorials

#online compiler for c     #python for programming    

#dfs and bfs algorithm     #programming with c language

#storageclass in C    #listcomprehension in python