Merge Sort Algorithm | Divide and Conquer Algo

preview_player
Показать описание
Schedule a meeting in case of any queries/guidance/counselling:

~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:

Follow me on my Facebook Page:

Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:

Naveen AutomationLabs Paid Courses:
GIT Hub Course:

Java & Selenium:

Java & API +POSTMAN + RestAssured + HttpClient:
Рекомендации по теме
Комментарии
Автор

Merge Sort is a popular sorting algorithm that follows the Divide and Conquer paradigm. It is an efficient algorithm that has a time complexity of O(n log n), making it suitable for sorting large datasets.

The basic idea behind Merge Sort is to divide the dataset into two halves, sort each half, and then merge them back together. The merging process involves comparing the first elements of the two sorted halves and selecting the smallest one to be added to the sorted list. This process continues until all elements have been merged into the final sorted list.

One of the advantages of Merge Sort is its stability. This means that it maintains the order of equal elements in the sorted list, which is important in certain applications. Another advantage is that it can be easily parallelized, making it suitable for distributed computing environments.

However, Merge Sort does require additional memory space for the temporary arrays used during the merging process, which can be a disadvantage in certain memory-constrained environments. Despite this, Merge Sort is a widely used algorithm in computer science and is often the sorting algorithm of choice for applications that require stable sorting of large datasets.

naveenautomationlabs
Автор

Naveen bhai, I seen your all DS videos. All are awsome and very helpful the way using showing in eclipse and run that. Can you please proceed further in this playlist

I am eagerly waiting for Merge sort code part, Quick Sort, Heap Sort, Redix sort, Counting Sort.

hiteshdarji
Автор

Thanks Naveen. for wonderful explanation.

jaijagadeesha
Автор

Thanks for explaining in such a detailed way..

ABAutomationHub
Автор

Thank you for the detailed explanation.

barath
Автор

Hi naveen, can you do videos on katalon integration with azure devops and running test cases there and ci/CD integration in azure devops

anuiv
Автор

Hi Sir,
Please Flipkart ke filters par ek video banao

CheroGaming
Автор

#include<bits/stdc++.h>
using namespace std;
void sorting(int a[], int l, int h);
void merge(int a[], int l, int mid, int h);


void sorting(int a[], int l, int h)
{

while(h>l)
{ int mid=l+(h-l)/2;
sorting(a, l, mid);
sorting(a, mid+1, h);
merge(a, l, mid, h);
}
}
void merge(int a[], int l, int mid, int h)
{
int temp[h-l+1];
int index=0, i=l, j=mid+1;
while(i<=mid && j<=h)
{
if(a[i]<=a[j])
{
temp[index]=a[i];
index++;
i++;
}
else{
temp[index]=a[j];
index++;
j++;
}
}
while(i<=mid)
{
temp[index]=a[i];
i++;
index++;
}
while(j<=h)
{
temp[index]=a[j];
j++;index++;
}
for(i=0;i<index;i++)
{
a[l+i]=temp[i];
}

}

int main()
{
int a[]={3, 6, 4, 9, 4, 6, 3, 7, 5, 8};
int size=sizeof(a)/sizeof(a[0]);
sorting(a, 0, size-1);
for(int i=0;i<size;i++)
{
cout<<a[i]<<" ";
}
}


the code is not running.it will be helpful if you could help me finding the problem

shohaghrudra