My Profile
Active Members
TodayLast 7 Days
more...
Awards & Gifts
Online Exams
Fresher Jobs
Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian
cities including Bangalore, Chennai, Hyderabad, Pune or Kochi
Resources
Find educational articles, blogs, discussion threads and other resources.
Colleges
Find details about any college in India or search for courses.
|
Merge Sort
Posted Date:
Total Responses: 0
Posted By: Rashina Member Level: Gold Points/Cash: 2
|
# include # include #include
void merge(int k[],int low,int mid,int high) { int i = low,j = mid+1,h = low,temp[20]; while((i <= mid) && (j <= high)) { if(k[i] <= k[j]) { temp[h] = k[i]; i++; } else { temp[h] = k[j]; j++; } h++; } if(i > mid) { while(j <= high) { temp[h] = k[j]; j++; h++; } } else { while(i <= mid) { temp[h] = k[i]; i++; h++; } } for(i = low;i <= high;i++) { k[i] = temp[i]; } clrscr(); cout <<"\nThe sorted array : "; for(i = low;i <= high;i++) { cout < } }
void mergesort(int k[],int low,int high) { int mid; if(low < high) { mid = ((low + high)/2); mergesort(k,low,mid); mergesort(k,mid+1,high); merge(k,low,mid,high); } }
void main() { int k[20],h; clrscr(); cout <<"\nEnter the no. of elements : "; cin >>h; for(int i = 0;i < h;i++) { cout <<"\nEnter element no. "< cin >>k[i]; } mergesort(k,0,h-1); getch(); }
|
Project Feedbacks
|
| Author: rajesh pandey | Member Level: Bronze | Revenue Score:  | gud
| | Author: pintu singh | Member Level: Bronze | Revenue Score:  | i like your project
|
|
|
| Post Feedback |
|
|
You must Sign In to post a feedback.
|
|
|
|
|
Advertise Here
|