随笔分类 -  sorting

merge sort
摘要:merge sort public class MergeSort{ public int[] mergeSort(int[] array){ if(array == null){ return array; } int[] helper = new int[array.length]; mergeSort(array, helpe... 阅读全文

posted @ 2018-09-20 18:05 猪猪🐷

Rainbow sort
摘要:Rainbow sort Notes: boundary condition is tricky for me public class RainbowSort{ public int[] rainbowSort(int[] array){ if(array == null || array.length <= 1){ return array; } ... 阅读全文

posted @ 2018-09-20 18:04 猪猪&#128055;

Quick sort
摘要:Quick sort When solving a design problem, when should I use merge sort vs quick sort, for instance ? Idea : big class, class 1 public class QuickSort{ public int[] quickSort(int[] array){ ... 阅读全文

posted @ 2018-09-20 18:04 猪猪&#128055;

Bucket sort
摘要:Bucket sort https://www.geeksforgeeks.org/bucket-sort-2/ Bucket sort, or bin sort, is a sorting algorithm that works by distributing the elements of an array into a number of buckets. Each bu... 阅读全文

posted @ 2018-09-20 18:03 猪猪&#128055;

Bubble sort
摘要:Bubble sort Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swapsthem... 阅读全文

posted @ 2018-09-20 18:02 猪猪&#128055;

selection sort
摘要:selection sort The algorithm proceeds by finding the smallest (or largest, depending on sorting order) element in the unsorted sublist, exchanging (swapping) it with the leftmost unsorted element ... 阅读全文

posted @ 2018-09-20 18:02 猪猪&#128055;

insertion sort
摘要:insertion sort Insertion sort is a simple sorting algorithm that works the way we sort playing cards in our hands. Time Complexity: O(n*2) Auxiliary Space: O(1) Boundary Cases: Insertion sort tak... 阅读全文

posted @ 2018-09-20 18:01 猪猪&#128055;

Quick select
摘要:Quick select https://www.youtube.com/watch?v=1vrdZiVmqno https://www.geeksforgeeks.org/quickselect-algorithm/ http://www.geekviewpoint.com/java/search/quickselect With unit test But this co... 阅读全文

posted @ 2018-09-20 18:00 猪猪&#128055;

merge sort
摘要:merge sort https://www.youtube.com/watch?v=iMT7gTPpaqw // time : nlogn // space: n // n : the number of elements in the array public class MergeSort{ public int[] mergeSort(int[] array){ ... 阅读全文

posted @ 2018-08-09 18:44 猪猪&#128055;

导航