Java Birleştirme Sıralama Algoritması (Java Merge Sort Algorithm)
Verinin hafızada sıralı tutulması için geliştirilen sıralama algoritmalarından (sorting algorithms) bir tanesidir. Basitçe sıralanacak olan diziyi ikişer elemanı kalan parçalara inene kadar sürekli olarak ikiye böler. Sonra bu parçaları kendi içlerinde sıralayarak birleştirir. Sonuçta elde edilen dizi sıralı dizinin kendisidir. Bu açıdan bir parçala fethet (divide and conquere) yaklaşımıdır.
package mergesort;
import java.util.Arrays;
/**
*
* @author Halil
*/
public class MergeSort {
public static void mergeSort(int[] dizi, int n)
{
if (n < 2) {
return;
}
int mid = n / 2;
int[] l = new int[mid];
int[] r = new int[n - mid];
for (int i = 0; i < mid; i++) {
l[i] = dizi[i];
}
for (int i = mid; i < n; i++) {
r[i - mid] = dizi[i];
System.out.println(Arrays.toString(dizi));
}
mergeSort(l, mid);
mergeSort(r, n - mid);
merge(dizi, l, r, mid, n - mid);
System.out.println(Arrays.toString(dizi));
}
public static void merge(
int[] a, int[] l, int[] r, int left, int right) {
int i = 0, j = 0, k = 0;
while (i < left && j < right) {
if (l[i] <= r[j]) {
a[k++] = l[i++];
}
else {
a[k++] = r[j++];
}
}
while (i < left) {
a[k++] = l[i++];
}
while (j < right) {
a[k++] = r[j++];
}
}
public static void main(String args[])
{
int[] dizi = { 5, 1,4,5,6,8};
int n= dizi.length;
MergeSort.mergeSort(dizi,n);
}
}
Many of your competitors are sitting at home and doing nothing.
Its perfect time to plan your marketing strategy. You have created good website but your site will not in Google until content and images are optimized correctly. We need to optimize your website for search engines and make it search engine friendly.
I have analyzed your site in-depth and you can view your website audit report at
https://businesspromoted.websiteauditserver.com/halilyanik.com
Your website is the reflection of your business. Without optimizing your website for search engines, you will not get any traction from any digital marketing channels such as Facebook, Google, LinkedIn, etc.
We can fix all these issues and run successful backlink building campaign for a monthly fee of $500.
Please let me know a good time and phone number to reach out to you and we will discuss plan of action. I will also include discount coupon and show you how to replicate competitor’s online marketing strategy.
Looking forward to working with you.
Adam P.
Business Development Manager
Business Promoted