From 8ab748a2e3428bd207acb9a6f2509087df03e668 Mon Sep 17 00:00:00 2001 From: Nalin Bhardwaj Date: Wed, 22 Feb 2017 13:22:45 +0000 Subject: [PATCH 1/2] Better triggers, added memory complexity, added comb sort, re-arranged in order of popularity --- .../cheat_sheets/json/array-sorting.json | 121 ++++++++++++++---- 1 file changed, 96 insertions(+), 25 deletions(-) diff --git a/share/goodie/cheat_sheets/json/array-sorting.json b/share/goodie/cheat_sheets/json/array-sorting.json index 0ea1084bba1..1e259879655 100644 --- a/share/goodie/cheat_sheets/json/array-sorting.json +++ b/share/goodie/cheat_sheets/json/array-sorting.json @@ -1,58 +1,67 @@ { "id": "array_sorting_cheat_sheet", "name": "Array Sorting Algorithms", - "description": "Summary of Big-O time complexities for Array Sorting Algorithms", + "description": "Summary of Big-O time and memory complexities for Array Sorting Algorithms when n = size of array, k = range of elements", "metadata": { "sourceName": "Wikipedia", "sourceUrl": "https://en.wikipedia.org/wiki/Sorting_algorithm" }, "aliases": [ - "array sorting algorithms", "array sorting algorithm", "sorting complexity" - + "array sorting", "array sorting algorithms", "array sorting algorithm", "sorting complexity", "sorting time complexity", "sorting memory complexity", "sorting algorithmic complexity", "sorting time", "sorting memory", "sorting algorithm", + "array sort", "array sort algorithms", "array sort algorithm", "sort complexity", "sort time complexity", "sort memory complexity", "sort algorithmic complexity", "sort time", "sort memory", "sort algorithm" ], "template_type": "code", "section_order": [ "Quick Sort", "Merge Sort", "Heap Sort", - "Tim Sort", "Bubble Sort", "Insertion Sort", "Selection Sort", - "Tree Sort", - "Shell Sort", "Bucket Sort", "Radix Sort", "Counting Sort", + "Tim Sort", + "Shell Sort", + "Tree Sort", + "Comb Sort", "Cube Sort" ], "sections": { "Quick Sort": [ { - "val": "n log( n )", + "val": "n ⋅ log( n )", "key": "Best" }, { - "val": "n log( n )", + "val": "n ⋅ log( n )", "key": "Average" }, { "val": "n²", "key": "Worst" + }, + { + "val": "n", + "key": "Auxiliary memory" } ], "Merge Sort": [ { - "val": "n log( n )", + "val": "n ⋅ log( n )", "key": "Best" }, { - "val": "n log( n )", + "val": "n ⋅ log( n )", "key": "Average" }, { - "val": "n log( n )", + "val": "n ⋅ log( n )", "key": "Worst" + }, + { + "val": "n", + "key": "Auxiliary memory" } ], "Tim Sort": [ @@ -62,25 +71,33 @@ }, { "key":"Average", - "val":"n log( n )" + "val":"n ⋅ log( n )" }, { "key":"Worst", - "val":"n log( n )" + "val":"n ⋅ log( n )" + }, + { + "val": "n", + "key": "Auxiliary memory" } ], "Heap Sort": [ { - "val": "n log( n )", + "val": "n ⋅ log( n )", "key": "Best" }, { - "val": "n log( n )", + "val": "n ⋅ log( n )", "key": "Average" }, { - "val": "n log( n )", + "val": "n ⋅ log( n )", "key": "Worst" + }, + { + "val": "Constant", + "key": "Auxiliary memory" } ], "Bubble Sort": [ @@ -95,6 +112,10 @@ { "val": "n²", "key": "Worst" + }, + { + "val": "Constant", + "key": "Auxiliary memory" } ], "Insertion Sort": [ @@ -109,6 +130,10 @@ { "val": "n²", "key": "Worst" + }, + { + "val": "Constant", + "key": "Auxiliary memory" } ], "Selection Sort": [ @@ -123,20 +148,28 @@ { "val": "n²", "key": "Worst" + }, + { + "val": "Constant", + "key": "Auxiliary memory" } ], "Tree Sort": [ { "key":"Best", - "val":"n log( n )" + "val":"n ⋅ log( n )" }, { "key":"Average", - "val":"n log( n )" + "val":"n ⋅ log( n )" }, { "key":"Worst", "val":"n²" + }, + { + "key":"Auxiliary memory", + "val":"n" } ], "Shell Sort": [ @@ -145,12 +178,16 @@ "key": "Best" }, { - "val": "( n log( n ) )²", + "val": "( n ⋅ log( n ) )²", "key": "Average" }, { - "val": "( n log( n ) )²", + "val": "( n ⋅ log( n ) )²", "key": "Worst" + }, + { + "val": "Constant", + "key": "Auxiliary memory" } ], "Bucket Sort": [ @@ -165,20 +202,28 @@ { "val": "n²", "key": "Worst" + }, + { + "val": "n ⋅ k", + "key": "Auxiliary memory" } ], "Radix Sort": [ { - "val": "nk", + "val": "n ⋅ k", "key": "Best" }, { - "val": "nk", + "val": "n ⋅ k", "key": "Average" }, { - "val": "nk", + "val": "n ⋅ k", "key": "Worst" + }, + { + "val": "n + k", + "key": "Auxiliary memory" } ], "Counting Sort": [ @@ -193,6 +238,28 @@ { "key":"Worst", "val":"n + k" + }, + { + "key":"Auxiliary memory", + "val":"n + k" + } + ], + "Comb Sort": [ + { + "key":"Best ", + "val":"n ⋅ log( n )" + }, + { + "key":"Average", + "val":"n² / 2ᵖ where p = number of increments" + }, + { + "key":"Worst", + "val":"n²" + }, + { + "key":"Auxiliary memory", + "val":"Constant" } ], "Cube Sort": [ @@ -202,11 +269,15 @@ }, { "key":"Average", - "val":"n log( n )" + "val":"n ⋅ log( n )" }, { "key":"Worst", - "val":"n log( n )" + "val":"n ⋅ log( n )" + }, + { + "key":"Auxiliary memory", + "val":"n" } ] } From 86d781b0c9b89f3e22b5fc0911a6c042c3873512 Mon Sep 17 00:00:00 2001 From: Nalin Bhardwaj Date: Wed, 22 Feb 2017 13:54:43 +0000 Subject: [PATCH 2/2] Fixed triggers --- share/goodie/cheat_sheets/json/array-sorting.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/goodie/cheat_sheets/json/array-sorting.json b/share/goodie/cheat_sheets/json/array-sorting.json index 1e259879655..a839b5d9ce7 100644 --- a/share/goodie/cheat_sheets/json/array-sorting.json +++ b/share/goodie/cheat_sheets/json/array-sorting.json @@ -7,7 +7,7 @@ "sourceUrl": "https://en.wikipedia.org/wiki/Sorting_algorithm" }, "aliases": [ - "array sorting", "array sorting algorithms", "array sorting algorithm", "sorting complexity", "sorting time complexity", "sorting memory complexity", "sorting algorithmic complexity", "sorting time", "sorting memory", "sorting algorithm", + "array sorting algorithms", "array sorting algorithm", "sorting complexity", "sorting time complexity", "sorting memory complexity", "sorting algorithmic complexity", "sorting time", "sorting memory", "sorting algorithm", "array sort", "array sort algorithms", "array sort algorithm", "sort complexity", "sort time complexity", "sort memory complexity", "sort algorithmic complexity", "sort time", "sort memory", "sort algorithm" ], "template_type": "code", @@ -246,7 +246,7 @@ ], "Comb Sort": [ { - "key":"Best ", + "key":"Best", "val":"n ⋅ log( n )" }, {