Skip to content

Commit 7335b24

Browse files
committed
Merge branch 'feature/readme' into develop
2 parents f28fa1a + 2bef036 commit 7335b24

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

README.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ List<String> list = Lists.asList(boxedArray);
170170
- Enumerate prime numbers, EPI#5.9: [c++](cpp-algorithm/src/array) | Enumerate prime numbers in the range.
171171
- Order elements in an array by even and odd: [c++](cpp-algorithm/src/array)(`EvenOdd`) | Order even and odd numbers in the array.
172172
- 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.
174174
- Random data sampling - compute permutation, EPI#5.14: [c++](cpp-algorithm/src/array)(`ComputeRandomPermutation`) | Compute permutation of the array generated by random sampling.
175175
- Replace elements - replace and remove: [c++](cpp-algorithm/src/array)(`ReplaceAndRemoveString1`) | Replace element and remove element in the array. Keep the array size.
176176
- 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()
471471
import com.google.common.collect.*;
472472
Map<String, Integer> map = Maps.newHashMap();
473473
Set<Integer> set = Sets.newHashSet();
474-
EnumMap<City, Country> map = Maps.newEnumMap(City.class);
475-
LinkedHashMap<String, Integer> map = Maps.newLinkedHashMap();
476-
LinkedHashSet<Integer> set = Sets.newLinkedHashSet();
474+
Map<City, Country> map = Maps.newEnumMap(City.class);
475+
Map<String, Integer> map = Maps.newLinkedHashMap();
476+
Set<Integer> set = Sets.newLinkedHashSet();
477477

478478
// guava multiset (implements Multiset<E>)
479479
import com.google.common.collect.*;
480-
HashMultiset<String> multiset = HashMultiset.create();
481-
TreeMultiset<String> multiset = TreeMultiset.create();
482-
LinkedHashMultiset<String> multiset = LinkedHashMultiset.create();
483-
ConcurrentHashMultiset<String> multiset = ConcurrentHashMultiset.create();
484-
ImmutableMultiset<String> multiset = ImmutableMultiset.of("a", "b", "c");
480+
Multiset<String> multiset = HashMultiset.create();
481+
Multiset<String> multiset = TreeMultiset.create();
482+
Multiset<String> multiset = LinkedHashMultiset.create();
483+
Multiset<String> multiset = ConcurrentHashMultiset.create();
484+
Multiset<String> multiset = ImmutableMultiset.of("a", "b", "c");
485485

486486
// guava multimap (implements Multimap<K, V>)
487487
import com.google.common.collect.*;
488-
ArrayListMultimap<String, Integer> multimap = ArrayListMultimap.create();
489-
HashMultimap<String, Integer> multimap = HashMultimap.create();
490-
LinkedListMultimap<String, Integer> multimap = LinkedListMultimap.create();
491-
LinkedHashMultimap<String, Integer> multimap = LinkedHashMultimap.create();
492-
TreeMultimap<String, Integer> multimap = TreeMultimap.create();
493-
ImmutableListMultimap<String, Integer> multimap = ImmutableListMultimap.of("a", 1, "a", 2, "b", 3);
494-
ImmutableSetMultimap<String, Integer> multimap = ImmutableSetMultimap.of("a", 1, "a", 2, "b", 3);
488+
Multimap<String, Integer> multimap = ArrayListMultimap.create();
489+
Multimap<String, Integer> multimap = HashMultimap.create();
490+
Multimap<String, Integer> multimap = LinkedListMultimap.create();
491+
Multimap<String, Integer> multimap = LinkedHashMultimap.create();
492+
Multimap<String, Integer> multimap = TreeMultimap.create();
493+
Multimap<String, Integer> multimap = ImmutableListMultimap.of("a", 1, "a", 2, "b", 3);
494+
Multimap<String, Integer> multimap = ImmutableSetMultimap.of("a", 1, "a", 2, "b", 3);
495495

496496
// guava bimap (implements BiMap<K, V>, Map<K, V>)
497497
import com.google.common.collect.*;
498-
HashBiMap<String, Integer> bimap = HashBiMap.create();
499-
ImmutableBiMap<String, Integer> bimap = ImmutableBiMap.of("a", 1, "b", 2);
500-
EnumBiMap<City, Country> bimap = EnumBiMap.create(City.class, Country.class);
501-
EnumHashBiMap<City, Integer> bimap = EnumHashBiMap.create(City.class);
498+
BiMap<String, Integer> bimap = HashBiMap.create();
499+
BiMap<String, Integer> bimap = ImmutableBiMap.of("a", 1, "b", 2);
500+
BiMap<City, Country> bimap = EnumBiMap.create(City.class, Country.class);
501+
BiMap<City, Integer> bimap = EnumHashBiMap.create(City.class);
502502

503503
// guava table (implements Table<R, C, V>)
504504
import com.google.common.collect.*;
@@ -555,7 +555,7 @@ contains(1), clear(), iterator()
555555

556556
// guava
557557
import com.google.common.collect.*;
558-
PriorityQueue<Integer> queue = Queues.newPriorityQueue();
558+
Queue<Integer> queue = Queues.newPriorityQueue();
559559
```
560560

561561
**Heap algorithms**
@@ -667,7 +667,7 @@ var list = new ArrayList<>(deque); // deque to list
667667

668668
// guava
669669
import com.google.common.collect.*;
670-
ArrayDeque<Integer> deque = Queues.newArrayDeque();
670+
Deque<Integer> deque = Queues.newArrayDeque();
671671
```
672672

673673
**Examples**
@@ -765,8 +765,8 @@ headSet(3), tailSet(3), subSet(2, 4), descendingSet()
765765

766766
// guava
767767
import com.google.common.collect.*;
768-
TreeMap<Integer, Integer> map = Maps.newTreeMap();
769-
TreeSet<Integer> set = Sets.newTreeSet();
768+
Map<Integer, Integer> map = Maps.newTreeMap();
769+
Set<Integer> set = Sets.newTreeSet();
770770
```
771771

772772
**Properties of Trees**
@@ -1105,39 +1105,39 @@ list.sort(Comparator.comparingInt(String::length));
11051105

11061106
**Sorting algorithms**
11071107

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)
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)
11091109

11101110
| **Case** | **Time complexity** | **Remarks** |
11111111
| :---------- | :-----------------: | :-------------------------------------------------------------------------------------- |
11121112
| **Best** | $O(n)$ | when the input list is already sorted in the desired order (ascending or descending) |
11131113
| **Worst** | $O(n^2)$ | when the input list is already sorted in the reverse order of the desired sorting order |
11141114
| **Average** | $O(n^2)$ | when the input list is in jumbled order |
11151115

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)
11171117

11181118
| **Case** | **Time complexity** | **Remarks** |
11191119
| ----------- | :-----------------: | -------------------------------------------------------------------------------------------------------------- |
11201120
| **Best** | $O(n + k)$ | when input elements are uniformly distributed<br> and each bucket contains roughly the same number of elements |
11211121
| **Worst** | $O(n^2)$ | when all elements are placed into a single bucket |
11221122
| **Average** | $O(n)$ | |
11231123

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)
11251125

11261126
| **Case** | **Time complexity** | **Remarks** |
11271127
| ----------- | :-----------------: | ------------------------------------------------------- |
11281128
| **Best** | $O(n + k)$ | when the input elements have a small range of values |
11291129
| **Worst** | $O(n + k)$ | when the input elements have a large range of values |
11301130
| **Average** | $O(n + k)$ | when the elements are distributed randomly in the array |
11311131

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)
11331133

11341134
| **Case** | **Time complexity** | **Remarks** |
11351135
| ----------- | :-----------------: | ----------- |
11361136
| **Best** | $O(n log n)$ | |
11371137
| **Worst** | $O(n log n)$ | |
11381138
| **Average** | $O(n log n)$ | |
11391139

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)
11411141

11421142
| **Case** | **Time complexity** | **Remarks** |
11431143
| ----------- | :-----------------: | ------------------------------------------------------------------------------- |
@@ -1171,7 +1171,7 @@ list.sort(Comparator.comparingInt(String::length));
11711171

11721172
**Examples**
11731173

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.
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.
11751175
- 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.
11761176
- Merge intervals, EPI#13.7, LeetCode#merge-intervals: [c++](cpp-algorithm/src/sort)(`MergeIntervals`) | Given a collection of intervals, merge all overlapping intervals.
11771177
- 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()
12531253
**Examples**
12541254
12551255
- 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.
12571257
- Look and say problem, EPI#6.7: [c++](cpp-algorithm/src/string)
12581258
- Palindrome, EPI#6.5: [c++](cpp-algorithm/src/string) | Check if a string is palindromic.
12591259
- 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()
12681268
12691269
- Introduction to Algorithms, 3rd Edition, by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein (CLRS)
12701270
- 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_
12741274
12751275
[:arrow_up_small: back to toc](#table-of-contents)

0 commit comments

Comments
 (0)