You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-34Lines changed: 34 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -170,7 +170,7 @@ List<String> list = Lists.asList(boxedArray);
170
170
-Enumerate prime numbers, EPI#5.9: [c++](cpp-algorithm/src/array) |Enumerate prime numbers in the range.
171
171
-Order elements in an array by even and odd: [c++](cpp-algorithm/src/array)(`EvenOdd`) |Order even and odd numbers in the array.
172
172
-Order elements in an array by specified order, EPI#5.8: [c++](cpp-algorithm/src/array)(`Rearrange`) |Rearrange arrays to have a specific order.
173
-
-Random data sampling - offline, EPI#5.12: [c++](cpp-algorithm/src/array)(`OfflineRandomSampling`) |Randomly select k elements from the array.
173
+
-Random data sampling - offline, EPI#5.12: [c++](cpp-algorithm/src/array)(`OfflineRandomSampling`) |Randomly select _k_ elements from the array.
174
174
-Random data sampling - compute permutation, EPI#5.14: [c++](cpp-algorithm/src/array)(`ComputeRandomPermutation`) |Compute permutation of the array generated by random sampling.
175
175
-Replace elements - replace and remove: [c++](cpp-algorithm/src/array)(`ReplaceAndRemoveString1`) |Replace element and remove element in the array. Keep the array size.
176
176
-Replace elements - replace and remove: [c++](cpp-algorithm/src/array)(`ReplaceAndRemoveString2`) |Replace element and remove element in the array
@@ -471,34 +471,34 @@ int[] result = map.entrySet().stream()
-Bubble sort, CLRS#2-problems2.2: [java](java-algorithm/src/main/java/com/example/algorithm/sort) |Bubble sort is a sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items, and swaps them if needed.<br>(`n` is the number of elements)
1108
+
-Bubble sort, CLRS#2-problems2.2: [java](java-algorithm/src/main/java/com/example/algorithm/sort) |Bubble sort is a sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items, and swaps them if needed.<br>(_n_ is the number of elements)
|**Best**| $O(n)$ | when the input list is already sorted in the desired order (ascending or descending) |
1113
1113
|**Worst**| $O(n^2)$ | when the input list is already sorted in the reverse order of the desired sorting order |
1114
1114
|**Average**| $O(n^2)$ | when the input list is in jumbled order |
1115
1115
1116
-
-Bucket sort, CLRS#8.4: [java](java-algorithm/src/main/java/com/example/algorithm/sort) |Bucket sort is a sorting algorithm that works by distributing the elements of an array into a number of buckets. Each bucket contains a range of values and the elements are sorted within these buckets using any of the suitable sorting algorithms (such as insertion sort, merge sort, selection sort).<br>(`n` is the number of elements and `k` is the number of buckets)
1116
+
-Bucket sort, CLRS#8.4: [java](java-algorithm/src/main/java/com/example/algorithm/sort) |Bucket sort is a sorting algorithm that works by distributing the elements of an array into a number of buckets. Each bucket contains a range of values and the elements are sorted within these buckets using any of the suitable sorting algorithms (such as insertion sort, merge sort, selection sort).<br>(_n_ is the number of elements and _k_ is the number of buckets)
|**Best**| $O(n + k)$ | when input elements are uniformly distributed<br> and each bucket contains roughly the same number of elements |
1121
1121
|**Worst**| $O(n^2)$ | when all elements are placed into a single bucket |
1122
1122
|**Average**| $O(n)$ ||
1123
1123
1124
-
-Counting sort, CLRS#8.2: [java](java-algorithm/src/main/java/com/example/algorithm/sort) |Counting sort is a non-comparative sorting algorithm that sorts the elements of an array by counting the occurrences of each element in the array. The count is stored in an auxiliary array and the sorting is done by mapping the count as an index of the auxiliary array. It is used as a subroutine in radix sort (CLRS#8.3).<br>(`n` is the number of elements and `k` is the range of input values)
1124
+
-Counting sort, CLRS#8.2: [java](java-algorithm/src/main/java/com/example/algorithm/sort) |Counting sort is a non-comparative sorting algorithm that sorts the elements of an array by counting the occurrences of each element in the array. The count is stored in an auxiliary array and the sorting is done by mapping the count as an index of the auxiliary array. It is used as a subroutine in radix sort (CLRS#8.3).<br>(_n_ is the number of elements and _k_ is the range of input values)
|**Best**| $O(n + k)$ | when the input elements have a small range of values |
1129
1129
|**Worst**| $O(n + k)$ | when the input elements have a large range of values |
1130
1130
|**Average**| $O(n + k)$ | when the elements are distributed randomly in the array |
1131
1131
1132
-
-Heap sort, CLRS#6: [java](java-algorithm/src/main/java/com/example/algorithm/sort) |Heap sort is a comparison-based sorting algorithm that uses a binary heap data structure to sort an array. It is used for the implementation of priority queue.<br>(`n` is the number of elements)
1132
+
-Heap sort, CLRS#6: [java](java-algorithm/src/main/java/com/example/algorithm/sort) |Heap sort is a comparison-based sorting algorithm that uses a binary heap data structure to sort an array. It is used for the implementation of priority queue.<br>(_n_ is the number of elements)
1133
1133
1134
1134
|**Case**|**Time complexity**|**Remarks**|
1135
1135
|-----------|:-----------------:|-----------|
1136
1136
|**Best**| $O(n log n)$ ||
1137
1137
|**Worst**| $O(n log n)$ ||
1138
1138
|**Average**| $O(n log n)$ ||
1139
1139
1140
-
-Insertion sort, CLRS#2.1: [c++](cpp-algorithm/src/sort), [java](java-algorithm/src/main/java/com/example/algorithm/sort) |Insertion sort is a comparison-based sorting algorithm that builds the final sorted array one element at a time. One of the fastest algorithms for sorting very small arrays (around 10 elements).<br>(`n` is the number of elements)
1140
+
-Insertion sort, CLRS#2.1: [c++](cpp-algorithm/src/sort), [java](java-algorithm/src/main/java/com/example/algorithm/sort) |Insertion sort is a comparison-based sorting algorithm that builds the final sorted array one element at a time. One of the fastest algorithms for sorting very small arrays (around 10 elements).<br>(_n_ is the number of elements)
-H-Index, EPI#13.3: [c++](cpp-algorithm/src/sort)(`HIndex`) |Compute the researcher's h-index given a citation count array. The h-index is the largest number `h` such that `h` articles have at least `h` citations each.
1174
+
-H-Index, EPI#13.3: [c++](cpp-algorithm/src/sort)(`HIndex`) |Compute the researcher's h-index given a citation count array. The h-index is the largest number _h_ such that _h_ articles have at least _h_ citations each.
1175
1175
- Intersection of two sorted arrays, EPI#13.1: [c++](cpp-algorithm/src/sort)(`IntersectTwoSortedArray`) | Compute the intersection of two sorted array. The input arrays may have duplicate entries, but the output should be free of duplicates.
1176
1176
- Merge intervals, EPI#13.7, LeetCode#merge-intervals: [c++](cpp-algorithm/src/sort)(`MergeIntervals`) | Given a collection of intervals, merge all overlapping intervals.
1177
1177
- Merge two sorted arrays, EPI#13.2, LeetCode#merge-sorted-array: [c++](cpp-algorithm/src/sort)(`MergeTwoSortedArray`) | Merge two sorted array. Merge the second array into the first array.
@@ -1253,7 +1253,7 @@ var str = collection.stream()
1253
1253
**Examples**
1254
1254
1255
1255
- Convert string, EPI#6.1: [c++](cpp-algorithm/src/string)(`IntToString`, `StringToInt`) | Convert integer to string and vice versa.
1256
-
- IP address validation, EPI#6.9: [c++](cpp-algorithm/src/string) | Validate IPv4 address that is in the form of `x.x.x.x` where `x` is a number between 0 and 255.
1256
+
- IP address validation, EPI#6.9: [c++](cpp-algorithm/src/string) | Validate IPv4 address that is in the form of _x.x.x.x_ where _x_ is a number between 0 and 255.
1257
1257
- Look and say problem, EPI#6.7: [c++](cpp-algorithm/src/string)
1258
1258
- Palindrome, EPI#6.5: [c++](cpp-algorithm/src/string) | Check if a string is palindromic.
1259
1259
- Print sine wave pattern string, EPI#6.10: [c++](cpp-algorithm/src/string)(`SineWaveString` and `PrintSineWaveString`) | Print a string in sine wave pattern.
@@ -1268,8 +1268,8 @@ var str = collection.stream()
1268
1268
1269
1269
- Introduction to Algorithms, 3rd Edition, by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein (CLRS)
1270
1270
- Discrete Mathematics and Its Applications, 8th Edition, by Kenneth H. Rosen
1271
-
- Cracking the Coding Interview, 6th Edition, by Gayle Laakmann McDowell | *CTCI*
1272
-
- Elements of Programming Interviews, 2nd Edition, by Adnan Aziz, Tsung-Hsien Lee and Amit Prakash | *EPI*
1273
-
- Classic Computer Science Problems in Python, by David Kopec | *CCSP*
1271
+
- Cracking the Coding Interview, 6th Edition, by Gayle Laakmann McDowell | _CTCI_
1272
+
- Elements of Programming Interviews, 2nd Edition, by Adnan Aziz, Tsung-Hsien Lee and Amit Prakash | _EPI_
1273
+
- Classic Computer Science Problems in Python, by David Kopec | _CCSP_
1274
1274
1275
1275
[:arrow_up_small: back to toc](#table-of-contents)
0 commit comments