NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

void mergesort(int arr[], int l, int m, int r){
int i, j, k;
//Sol ve sağ dizi için değişkenker
int n1 = m - l + 1;
int n2 = r - m;
//Geçici dizilerimiz, boyutları dizimizi ikiye böleceğimiz esasına göre oluşturuyoruz.
int L[n1], R[n2];
//Aşağıdaki iki döngü geçici dizilerimize elemanları atıyor.
for (i = 0; i < n1; i++)
L[i] = arr[l + i];
for (j = 0; j < n2; j++)
R[j] = arr[m + 1+ j];
//Yukarıda yaptığımız işlemlerden ötürü değişkenlerimizin sayıları değişti, burada fabrika ayarlarına döndürüyoruz.
i = 0;
j = 0;
k = l;
//Esas birleştirme mevzusu burada dönüyor.
//sol ve sağ dizide eleman oldukça döngümüz dönecek
while (i < n1 && j < n2){
//Eğer sol dizinin i. indisindeki eleman, sağ dizinin j. indisindeki elemandan küçük eşitse
//yeni oluşturulacak dizinin ilk elemanı sol dizinin ilk elemanı oluyor.
if (L[i] <= R[j]){
arr[k] = L[i];
i++;
}
//Yok değilse sağ dizinin ilk elemanı yeni dizimizin ilk elemanı oluyor.
else{
arr[k] = R[j];
j++;
}
//dikkat edin, k değişkenini her durumda artırıyoruz.
k++;
}
//Eğer atama işlemlerinden sonra sol dizide boşta eleman kaldıysa boşta kalan yerlere yerleştiriyoruz.
while (i < n1){
arr[k] = L[i];
i++;
k++;
}
//Eğer atama işlemlerinden sonra sağ dizide boşta eleman kaldıysa boşta kalan yerlere yerleştiriyoruz.
while (j < n2){
arr[k] = R[j];
j++;
k++;
}
}

float merge(int arr[], int l, int r){
//sol sağdan küçükse statement'a gider, bu şartı koymasaydık en küçük parçalara ayrılmasının kontrolünü yapamazdık..
clock_t ilk,son;
ilk=clock();
if (l < r){
//dizinin ortasını hesaplıyoruz.
int m = l+(r-l)/2;
merge(arr, l, m);
merge(arr, m+1, r);
//Esas fonksiyona dizimizi, sol indisi, orta indisi ve sağ indisi parametre olarak yolluyoruz
mergesort(arr, l, m, r);
}
son=clock();
return (float) (son-ilk);
}

float quick(int arr[], int left, int right)
{
int i = left, j = right;
int temp;
int pivot = arr[(left + right) / 2];
clock_t ilk,son;
ilk=clock();
while (i <= j) {
while (arr[i] < pivot)
i++;
while (arr[j] > pivot)
j--;
if (i <= j) {
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
i++;
j--;
}
};
if (left < j)
quick(arr, left, j);
if (i < right)
quick(arr, i, right);
son=clock();
return (float) (son-ilk);
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.