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
-Compute the k closest stars (`FindClosestStar`): [c++](cpp-algorithm/src/heap) |Find the $k$ closest stars to the earth. The stars are represented by a sequence of points(coordinates).
477
481
-Compute the median of a sequence of numbers (`FindMedian`): [c++](cpp-algorithm/src/heap) |Find the median of a sequence of numbers. The median is the number separating the higher half of a data sample from the lower half.
478
-
-Fibonacci heap
479
482
-Merge sorted arrays (`MergeSortedArray`): [c++](cpp-algorithm/src/heap) |Merge k sorted arrays into one heap.
480
483
-Sort an increasing-decreasing array (`SortIncreasingDecreasingArray`): [c++](cpp-algorithm/src/heap) |Sort an array that is repeatedly increasing then decreasing.
-Inorder traversal (left, root, right): best choice for applications where internal vertices must be explored in-order.
685
688
-Postorder traversal (left, right, root): best choice for applications where leaves need to be explored before internal vertices.
686
689
687
-
**Examples**
690
+
**Tree algorithms**
688
691
689
692
-AVL tree
690
693
-B-tree: [c++](cpp-algorithm/src/tree) |B-tree is a self-balancing data structure which can have many child nodes. It is commonly used in auxiliary storage devices and database system. B-tree has the following properties:1) Nodes have lower and upper bounds on the number of keys they can contain. (represent using degree $t$) 2) Every node other than the root must have at least $t-1$ keys. 3) Every node may contain at most $2t-1$ keys.
691
-
-Balanced tree status: [c++](cpp-algorithm/src/tree) |Whether the binary tree is balanced or not.
692
694
-Binary search tree: [c++](cpp-algorithm/src/tree) |In binary search tree, all internal nodes are stored in ordered state. If $y$ is a child of $x$ and $y$ is a node in the left subtree, then $y.key \leq x.key$, and if $y$ is a node in the right subtree, then $y.key \geq x.key$.
695
+
-Red-black tree
696
+
-Trie
697
+
- van EmdeBoas tree (vEB tree)
698
+
699
+
**Examples**
700
+
701
+
-Balanced tree status: [c++](cpp-algorithm/src/tree) |Whether the binary tree is balanced or not.
693
702
-Binary tree exterior (`CreateExteriorNodeList`): [c++](cpp-algorithm/src/tree) |Create a vector of exterior nodes in a binary tree.
694
703
-Construct binary tree from preorder and inorder traversal (`ConstructTreeFromPreorderInorder`): [c++](cpp-algorithm/src/tree) |Construct a binary search tree from preorder and inorder traversal. This task has $O(n)$ time complexity.
695
704
-Construct binary tree from preorder with marker (`ConstructTreeFromMarkerPreorder`): [c++](cpp-algorithm/src/tree) |Construct a binary search tree from preorder traversal with marker. This task has $O(n)$ time complexity.
696
705
-Leaf node list (`CreateLeafNodeList`): [c++](cpp-algorithm/src/tree) |Create a vector of leaf nodes in a binary tree.
697
706
-Lowest common ancestor (`FindLowestCommonAncestor`): [c++](cpp-algorithm/src/tree) |Find the lowest common ancestor of two nodes in a binary tree.
698
707
-Lowest common ancestor with parent pointer (`FindLowestCommonAncestor2`): [c++](cpp-algorithm/src/tree) |Find the lowest common ancestor of two nodes in a binary tree. The nodes have parent pointers.
699
708
-Populate right sibling (`PopulateRightSibling`): [c++](cpp-algorithm/src/tree) |Populate the right sibling of a binary tree.
700
-
-Red-black search tree
701
709
-Root to leaf path corresponding to the given sum (`HasKeySum`): [c++](cpp-algorithm/src/tree) |Whether the tree has a root-leaf path equal to the given sum.
702
710
-Sum of root to leaf (`SumRootToLeafDecimal`, `SumRootToLeafBinary`): [c++](cpp-algorithm/src/tree) |Sum of all root to leaf paths in a binary tree (decimal and binary representation).
703
711
-Tree symmetric: [c++](cpp-algorithm/src/tree) |Whether the binary tree is symmetric or not.
704
-
-Trie
705
-
- van EmdeBoas tree (vEB tree)
706
712
707
713
[:arrow_up_small: back to toc](#table-of-contents)
var randomBoolean = random.nextBoolean(); // true/false
861
867
```
862
868
863
-
**Examples**
869
+
**Primitive type algorithms**
864
870
865
871
-Arithmetic operation (`Multiply`/`Divide`), EPI#4.5, EPI#4.6: [c++](cpp-algorithm/src/primitive_type) |Calculate the product/fraction of two numbers without using arithmetic operators.
-Rectangle intersection, EPI#4.11: [c++](cpp-algorithm/src/primitive_type) |Checkif two rectangles intersect.
874
883
-Reverse digits, EPI#4.8: [c++](cpp-algorithm/src/primitive_type) |Reverse the digits of a given integer.
875
884
-Swap bit, EPI#4.2: [c++](cpp-algorithm/src/primitive_type) |Swap the bits at indices $i$ and $j$.
@@ -923,14 +932,17 @@ Arrays.binarySearch(array, 3) // for array
923
932
Collections.binarySearch(arrayList, 3); // for list
924
933
```
925
934
926
-
**Examples**
935
+
**Search algorithms**
927
936
928
937
-Binary search: [python](python-algorithm/algorithm/search) |Binary search is a search algorithm that finds the position of a target value within a sorted array.
929
-
-Find k-th smallest/largest element in an array (`FindKthSmallestElement`/`FindKthLargestElement`), EPI#11.8: [c++](cpp-algorithm/src/search) |Find the k-th smallest/largest element in an array using the quickselect algorithm (`QuickSelectAlgorithm`).
930
-
-Find the minimum and maximum elements in an array (`FindMinMax`), EPI#11.7: [c++](cpp-algorithm/src/search)
931
938
-Integer square root (`ComputeIntegerSquareRoot`), EPI#11.4: [c++](cpp-algorithm/src/search) |Compute the integer square root of a given integer. This function returns the largest integer whose square is less than or equal to the given integer.
932
939
-Linear search: [python](python-algorithm/algorithm/search) |Linear search is a search algorithm that compares x successively with each term of the list until a match is found.
933
940
-Quick select algorithm (`QuickSelectAlgorithm`): [c++](cpp-algorithm/src/search) |QuickSelect is an algorithm used to select the k-th smallest (or largest) element in an unordered list of elements.
941
+
942
+
**Examples**
943
+
944
+
-Find k-th smallest/largest element in an array (`FindKthSmallestElement`/`FindKthLargestElement`), EPI#11.8: [c++](cpp-algorithm/src/search) |Find the k-th smallest/largest element in an array using the quickselect algorithm (`QuickSelectAlgorithm`).
945
+
-Find the minimum and maximum elements in an array (`FindMinMax`), EPI#11.7: [c++](cpp-algorithm/src/search)
934
946
-Search a sorted array for entry equal to its index (`SearchEntryEqualToItsIndex`), EPI#11.2: [c++](cpp-algorithm/src/search)
935
947
-Search a sorted array for the first greater than a key (`SearchFirstGreaterThanKey`): [c++](cpp-algorithm/src/search)
936
948
-Search a sorted array for the first occurrence of a key (`SearchFirstOfKey`), EPI#11.1: [c++](cpp-algorithm/src/search)
@@ -1114,17 +1126,20 @@ var str = collection.stream()
- Naive string matching: [c++](cpp-algorithm/src/string), [python](python-algorithm/algorithm/string) | Find all occurrences of a pattern in a string.
1134
+
- Rabin-Karp algorithm, EPI#6.12: [c++](cpp-algorithm/src/string) | Use the hash function to find all occurrences of a pattern in a string. It has $\theta(\text{pattern-size})$ preprocessing time and $\theta((\text{text-size} - \text{pattern-size} + 1) \text{pattern-size})$ time complexity.
1135
+
1117
1136
**Examples**
1118
1137
1119
1138
- Convert string (`IntToString`, `StringToInt`), EPI#6.1: [c++](cpp-algorithm/src/string) | Convert integer to string and vice versa.
1120
-
- Finite automata
1121
1139
- 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.
1122
-
- Knuth-Morris-Pratt algorithm (KMP)
1123
1140
- Look and say problem, EPI#6.7: [c++](cpp-algorithm/src/string)
1124
-
- Naive string matching: [c++](cpp-algorithm/src/string), [python](python-algorithm/algorithm/string) | Find all occurrences of a pattern in a string.
1125
1141
- Palindrome, EPI#6.5: [c++](cpp-algorithm/src/string) | Check if a string is palindromic.
1126
1142
- Print sine wave pattern string (`SineWaveString` and `PrintSineWaveString`), EPI#6.10: [c++](cpp-algorithm/src/string) | Print a string in sine wave pattern.
1127
-
- Rabin-Karp algorithm, EPI#6.12: [c++](cpp-algorithm/src/string) | Use the hash function to find all occurrences of a pattern in a string. It has $\theta(\text{pattern-size})$ preprocessing time and $\theta((\text{text-size} - \text{pattern-size} + 1) \text{pattern-size})$ time complexity.
1128
1143
- Roman number (`VerifyRomanString`), EPI#6.8: [c++](cpp-algorithm/src/string) | Verify if a string is a valid roman number.
1129
1144
- Roman number (`RomanStringToInteger`), EPI#6.8: [c++](cpp-algorithm/src/string) | Convert a roman number to integer.
1130
1145
- Run-length encoding (RLE), EPI#6.11: [c++](cpp-algorithm/src/string) | Run-length encoding is a simple form of data compression in which runs of data are stored as a single data value and count.
0 commit comments