NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Seçmeli Sıralama (Selection Sort)
________________________________________
int[] array={3,5,2,7,1,9};
int array2;
for (int k=0;k<array.length;k++){
int minIndex=k;
for (int i=k+1;i<array.length;i++){
if (array[i]<array[minIndex]){
minIndex=i;
}

}
array2= array[k];
array[k]=array[minIndex];
array[minIndex]=array2;
}
for (int i=0;i<array.length;i++){
System.out.println(array[i]+ " ");
}

---------------------------

Hızlı Sıralama(Quick Sort)
________________________________________
import java.util.Arrays;

public class QuickSort
{
public static void main(String[] args)
{
Integer[] array = new Integer[] { 12, 13, 24, 10, 3, 6, 90, 70 };

quickSort( array, 0, array.length - 1 );

System.out.println(Arrays.toString(array));
}

public static void quickSort(Integer[] arr, int dusuk, int yuksek)
{
if (dusuk >= yuksek){
return;
}
int middle = dusuk + (yuksek - dusuk) / 2;
int pivot = arr[middle];

int i = dusuk, j = yuksek;
while (i <= j)
{
while (arr[i] < pivot)
{
i++;
}
while (arr[j] > pivot) {
j--;
}
if (i <= j)
{
swap (arr, i, j);
i++;
j--;
}
}
if (dusuk < j){
quickSort(arr, dusuk, j);
}
if (yuksek > i){
quickSort(arr, i, yuksek);
}
}

public static void swap (Integer array[], int x, int y)
{
int temp = array[x];
array[x] = array[y];
array[y] = temp;
}
}



---------------------------

Eklemeli Sıralama (Insertion Sort)
________________________________________
public class Insertion {
public static void main(String [] args)
{
int[] nums = {31,1,56,33,777,123,25,15,17,20,11,10,1,23,3};
Insertion dz = new Insertion();
dz.Sort(nums);
dz.print(nums);
}

private void Sort(int[] nums){
int temp = 0;
int lenght = nums.length;
for(int i = 1; i < lenght; i++) // 1den başlayarak dizinin sonuna kadar devam et
{
if(nums[i] < nums[i-1]) // büyük ile küçüğü değiştir ve tekrar indis 1 e git.
{
temp = nums[i]; // dizide indisler arası değişiklik olacağından
nums[i] = nums[i-1]; // temp adında bir değişkene ihtiyaç duyarız.
nums[i-1] = temp;
i = 1;
}
}
}
private void print(int[] nums)
{
for(int i = 0; i < nums.length; i++)
{
System.out.print(nums[i] + " ");
}
}
}
----------------------------------
Bubble Sort (Baloncuk/Kabarcık Sıralama)
___________________________________________________
import java.util.Arrays;
public class BubleSort {
int[] a = {3,17,86,-9,7,-11,38} ;
public static void main(String[] args) {
BubleSort bbs = new BubleSort();
System.out.println("nSıralamadan önce:");
System.out.println(Arrays.toString(bbs.a));
Arrays.sort(bbs.a);
System.out.println("nnSıralamadan sonra:");
System.out.println(Arrays.toString(bbs.a));
}
}
----------------------------------
     
 
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.