Skip to content

Commit 7e96282

Browse files
author
=
committed
Updated changes in merge sort in Lab 2
1 parent b690b2a commit 7e96282

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Lab2/a.out

4.73 KB
Binary file not shown.

Lab2/merge.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include<iostream>
2+
#include<time.h>
23
using namespace std;
34
//l is lowest index and r is the max index (left and right)
45
void merge(int A[],int l,int m ,int r)
@@ -68,6 +69,8 @@ merge(A,l,m,r);
6869
int main()
6970
{
7071
int n,l,r,i;
72+
clock_t start,end;
73+
float t;
7174
cout<<"Enter the array size you want: ";
7275
cin>>n;
7376
int A[n];
@@ -77,9 +80,13 @@ cout<<"Enter "<<i+1<<" element of the array: ";
7780
cin>>A[i];
7881
}
7982
cout<<"Lets do merge sorting"<<endl;
83+
start=clock();
8084
mergesort(A,0,n-1);
85+
end=clock();
8186
for(i=0;i<n;i++)
8287
{
8388
cout<<i+1<<" element of the array is: "<<A[i]<<endl;
8489
}
90+
t=float(end-start)/CLOCKS_PER_SEC;
91+
cout<<"Time taken to perform merge sort is: "<<t<<endl;
8592
}

0 commit comments

Comments
 (0)