Kayıtlar

2018 tarihine ait yayınlar gösteriliyor

Sort methods in java

Resim
public class Sorts { /**  * @author Alihan98ersoy  * 01.07.2017(month,day,year)  * Contents:  * Selection Sort  * İnsertion Sort  * Shell Sort  * Quick Sort  */ // Selection sort //Find smallest number in second for replace it with first for integer i. public void Selectionsort(int[]list){ for(int i=0;i<list.length;i++){ int indexofsmallestnumber=i; for(int j=i+1;j<list.length;j++){ if(list[j]<list[indexofsmallestnumber])  {indexofsmallestnumber=j;} } int basket=list[indexofsmallestnumber];//basket for replace list[indexofsmallestnumber]=list[i]; list[i]=basket; } }  /* İnsertion sort *İnsertion is good for small elements only because it requires more time for sorting a large number of elements. *Find the smallest number and put it correct place with comparing it every to until finding the correct place. *insertionSort works pretty well for partially sor...

Linear and Binary search methods in java

Resim
public class Search_methods { /**         * @author Alihan98ersoy         * 01.07.2017(month,day,year)         * Contents:         * Linear Search         * Binary Search */        //Linear Search        //Searching one by one        public int LinearSearch( int [] list , int target ){              for ( int i =0; i < list . length ; i ++){                     if ( list [ i ]== target ){ return i ; }              }        ...