Created
October 9, 2019 13:55
-
-
Save belushkin/e415f7cb1fff1245142c454f5fb50e74 to your computer and use it in GitHub Desktop.
Check this merge tomorrow and write merge, quick and counting together
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <bits/stdc++.h> | |
int a[] = {9,3,1,4,5,7,7,2,2}; | |
void merge(int a[], int left, int middle, int right) { | |
int n1 = middle-left+1; | |
int n2 = right-midlle; | |
int L1[n1]; | |
int R2[n2]; | |
for (int i = left; i < n1; i++) { | |
L1 = a[i] | |
} | |
for (int i = 0; i < n2; i++) { | |
R2 = a[i+middle]; | |
} | |
i = 0; | |
j = 0; | |
k = 0; | |
while(i < n1 and j < n2) { | |
if (L1[i] < R2[i]) | |
} | |
} | |
void merge_sort(int a[], int left, int right) { | |
if (left < right) { | |
int middle = (right+left)/2; | |
merge_sort(a, 0, middle); | |
merge_sort(a, middle+1, rihgt); | |
merge(a, left, middle, right); | |
} | |
} | |
int main() { | |
int n = sizeof(a)/sizeof(a[0]); | |
merge_sort(a, 0, n-1); | |
for (int i = 0; i<n; i++) { | |
std::cout << a[i] << " "; | |
} | |
std::cout << "\n"; | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment