diff --git a/d0/d52/duval_8cpp__incl.map b/d0/d52/duval_8cpp__incl.map new file mode 100644 index 000000000..e39715036 --- /dev/null +++ b/d0/d52/duval_8cpp__incl.map @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/d0/d52/duval_8cpp__incl.md5 b/d0/d52/duval_8cpp__incl.md5 new file mode 100644 index 000000000..6328c5ca7 --- /dev/null +++ b/d0/d52/duval_8cpp__incl.md5 @@ -0,0 +1 @@ +eae7d85379eba1e90592ec01d425390b \ No newline at end of file diff --git a/d0/d52/duval_8cpp__incl.svg b/d0/d52/duval_8cpp__incl.svg new file mode 100644 index 000000000..90239835c --- /dev/null +++ b/d0/d52/duval_8cpp__incl.svg @@ -0,0 +1,173 @@ + + + + + + + + + + + + +strings/duval.cpp + + +Node1 + + +strings/duval.cpp + + + + + +Node2 + + +array + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +cassert + + + + + +Node1->Node3 + + + + + + + + +Node4 + + +cstddef + + + + + +Node1->Node4 + + + + + + + + +Node5 + + +deque + + + + + +Node1->Node5 + + + + + + + + +Node6 + + +iostream + + + + + +Node1->Node6 + + + + + + + + +Node7 + + +string + + + + + +Node1->Node7 + + + + + + + + +Node8 + + +vector + + + + + +Node1->Node8 + + + + + + + + + + + + + diff --git a/d0/d52/duval_8cpp__incl_org.svg b/d0/d52/duval_8cpp__incl_org.svg new file mode 100644 index 000000000..045e2f8d2 --- /dev/null +++ b/d0/d52/duval_8cpp__incl_org.svg @@ -0,0 +1,147 @@ + + + + + + +strings/duval.cpp + + +Node1 + + +strings/duval.cpp + + + + + +Node2 + + +array + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +cassert + + + + + +Node1->Node3 + + + + + + + + +Node4 + + +cstddef + + + + + +Node1->Node4 + + + + + + + + +Node5 + + +deque + + + + + +Node1->Node5 + + + + + + + + +Node6 + + +iostream + + + + + +Node1->Node6 + + + + + + + + +Node7 + + +string + + + + + +Node1->Node7 + + + + + + + + +Node8 + + +vector + + + + + +Node1->Node8 + + + + + + + + diff --git a/d6/dd6/namespacestring.html b/d6/dd6/namespacestring.html new file mode 100644 index 000000000..e38289033 --- /dev/null +++ b/d6/dd6/namespacestring.html @@ -0,0 +1,193 @@ + + + + + + + +Algorithms_in_C++: string Namespace Reference + + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Algorithms_in_C++ 1.0.0 +
+
Set of algorithms implemented in C++.
+
+
+ + + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
string Namespace Reference
+
+
+ +

string manipulation algorithms +More...

+ + + + + + +

+Functions

template<typename T >
size_t duval (const T &s)
 Find the lexicographically smallest cyclic shift of a sequence.
 
+

Detailed Description

+

string manipulation algorithms

+

for std::array for assert for std::size_t for std::deque for std::cout and std::endl for std::string for std::vector

+

Function Documentation

+ +

◆ duval()

+ +
+
+
+template<typename T >
+ + + + + + + +
size_t string::duval (const T & s)
+
+ +

Find the lexicographically smallest cyclic shift of a sequence.

+
Template Parameters
+ + +
Ttype of the sequence
+
+
+
Parameters
+ + +
sthe sequence
+
+
+
Returns
the 0-indexed position of the least cyclic shift of the sequence
+
49 {
+
50 size_t n = s.size();
+
51 size_t i = 0, ans = 0;
+
52 while (i < n) {
+
53 ans = i;
+
54 size_t j = i + 1, k = i;
+
55 while (j < (n + n) && s[j % n] >= s[k % n]) {
+
56 if (s[k % n] < s[j % n]) {
+
57 k = i;
+
58 } else {
+
59 k++;
+
60 }
+
61 j++;
+
62 }
+
63 while (i <= k) {
+
64 i += j - k;
+
65 }
+
66 }
+
67 return ans;
+
68 // returns 0-indexed position of the least cyclic shift
+
69}
+
double k(double x)
Another test function.
Definition composite_simpson_rule.cpp:117
+
+
+
+
+
+ + + + diff --git a/db/d09/duval_8cpp.html b/db/d09/duval_8cpp.html new file mode 100644 index 000000000..291310b08 --- /dev/null +++ b/db/d09/duval_8cpp.html @@ -0,0 +1,268 @@ + + + + + + + +Algorithms_in_C++: strings/duval.cpp File Reference + + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Algorithms_in_C++ 1.0.0 +
+
Set of algorithms implemented in C++.
+
+
+ + + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
duval.cpp File Reference
+
+
+ +

Implementation of Duval's algorithm. +More...

+
#include <array>
+#include <cassert>
+#include <cstddef>
+#include <deque>
+#include <iostream>
+#include <string>
+#include <vector>
+
+Include dependency graph for duval.cpp:
+
+
+
+
+ + + + +

+Namespaces

namespace  string
 string manipulation algorithms
 
+ + + + + + + + + + + +

+Functions

template<typename T >
size_t string::duval (const T &s)
 Find the lexicographically smallest cyclic shift of a sequence.
 
static void test ()
 self test implementation returns void
 
int main ()
 main function
 
+

Detailed Description

+

Implementation of Duval's algorithm.

+

Duval's algorithm is an algorithm to find the lexicographically smallest rotation of a string. It is based on the concept of Lyndon words. Lyndon words are defined as the lexicographically smallest string in a rotation equivalence class. A rotation equivalence class is a set of strings that can be obtained by rotating a string. For example, the rotation equivalence class of "abc" is {"abc", "bca", "cab"}. The lexicographically smallest string in this class is "abc".

+

Duval's algorithm works by iterating over the string and finding the smallest rotation of the string that is a Lyndon word. This is done by comparing the string with its suffixes and finding the smallest suffix that is lexicographically smaller than the string. This suffix is then added to the result and the process is repeated with the remaining string. The algorithm has a time complexity of O(n) where n is the length of the string.

+
Note
While Lyndon words are described in the context of strings, Duval's algorithm can be used to find the lexicographically smallest cyclic shift of any sequence of comparable elements.
+
Author
Amine Ghoussaini
+

Function Documentation

+ +

◆ main()

+ +
+
+ + + + + + + +
int main (void )
+
+ +

main function

+
Returns
0 on exit
+
115 {
+
116 test(); // run self test implementations
+
117 return 0;
+
118}
+
static void test()
self test implementation returns void
Definition duval.cpp:77
+
+Here is the call graph for this function:
+
+
+
+ +
+
+ +

◆ test()

+ +
+
+ + + + + +
+ + + + + + + +
static void test ()
+
+static
+
+ +

self test implementation returns void

+
77 {
+
78 using namespace string;
+
79
+
80 // Test 1
+
81 std::string s1 = "abcab";
+
82 assert(duval(s1) == 3);
+
83
+
84 // Test 2
+
85 std::string s2 = "011100";
+
86 assert(duval(s2) == 4);
+
87
+
88 // Test 3
+
89 std::vector<int> v = {5, 2, 1, 3, 4};
+
90 assert(duval(v) == 2);
+
91
+
92 // Test 4
+
93 std::array<int, 5> a = {1, 2, 3, 4, 5};
+
94 assert(duval(a) == 0);
+
95
+
96 // Test 5
+
97 std::deque<char> d = {'a', 'z', 'c', 'a', 'b'};
+
98 assert(duval(d) == 3);
+
99
+
100 // Test 6
+
101 std::string s3;
+
102 assert(duval(s3) == 0);
+
103
+
104 // Test 7
+
105 std::vector<int> v2 = {5, 2, 1, 3, -4};
+
106 assert(duval(v2) == 4);
+
107
+
108 std::cout << "All tests passed!" << std::endl;
+
109}
+ + + + +
T endl(T... args)
+
string manipulation algorithms
Definition duval.cpp:41
+
size_t duval(const T &s)
Find the lexicographically smallest cyclic shift of a sequence.
Definition duval.cpp:49
+ +
+Here is the call graph for this function:
+
+
+
+ +
+
+
+
+ + + + diff --git a/db/d09/duval_8cpp.js b/db/d09/duval_8cpp.js new file mode 100644 index 000000000..69777b32a --- /dev/null +++ b/db/d09/duval_8cpp.js @@ -0,0 +1,6 @@ +var duval_8cpp = +[ + [ "duval", "db/d09/duval_8cpp.html#ac2a35302e6bed93c4b2c6f55a21a5632", null ], + [ "main", "db/d09/duval_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4", null ], + [ "test", "db/d09/duval_8cpp.html#aa8dca7b867074164d5f45b0f3851269d", null ] +]; \ No newline at end of file diff --git a/db/d09/duval_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map b/db/d09/duval_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map new file mode 100644 index 000000000..1853db70f --- /dev/null +++ b/db/d09/duval_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/db/d09/duval_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 b/db/d09/duval_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 new file mode 100644 index 000000000..79b328cc0 --- /dev/null +++ b/db/d09/duval_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 @@ -0,0 +1 @@ +0f712e92fb452db1f16641cf4d4a41f1 \ No newline at end of file diff --git a/db/d09/duval_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg b/db/d09/duval_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg new file mode 100644 index 000000000..d3bffbbf3 --- /dev/null +++ b/db/d09/duval_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg @@ -0,0 +1,65 @@ + + + + + + + + + + + + +test + + +Node1 + + +test + + + + + +Node2 + + +std::endl + + + + + +Node1->Node2 + + + + + + + + + + + + + diff --git a/db/d09/duval_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph_org.svg b/db/d09/duval_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph_org.svg new file mode 100644 index 000000000..384dd1181 --- /dev/null +++ b/db/d09/duval_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph_org.svg @@ -0,0 +1,39 @@ + + + + + + +test + + +Node1 + + +test + + + + + +Node2 + + +std::endl + + + + + +Node1->Node2 + + + + + + + + diff --git a/db/d09/duval_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map b/db/d09/duval_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map new file mode 100644 index 000000000..13647bb3b --- /dev/null +++ b/db/d09/duval_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map @@ -0,0 +1,7 @@ + + + + + + + diff --git a/db/d09/duval_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 b/db/d09/duval_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 new file mode 100644 index 000000000..1b359626b --- /dev/null +++ b/db/d09/duval_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 @@ -0,0 +1 @@ +01a04610bd48d17509f81817a2e9ea57 \ No newline at end of file diff --git a/db/d09/duval_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg b/db/d09/duval_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg new file mode 100644 index 000000000..3011a8167 --- /dev/null +++ b/db/d09/duval_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg @@ -0,0 +1,83 @@ + + + + + + + + + + + + +main + + +Node1 + + +main + + + + + +Node2 + + +test + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +std::endl + + + + + +Node2->Node3 + + + + + + + + + + + + + diff --git a/db/d09/duval_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph_org.svg b/db/d09/duval_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph_org.svg new file mode 100644 index 000000000..3318854a6 --- /dev/null +++ b/db/d09/duval_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph_org.svg @@ -0,0 +1,57 @@ + + + + + + +main + + +Node1 + + +main + + + + + +Node2 + + +test + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +std::endl + + + + + +Node2->Node3 + + + + + + + + diff --git a/dir_73a3cc5065b223eb41b02873c0e19f0e.html b/dir_73a3cc5065b223eb41b02873c0e19f0e.html index 0c91e5d08..6b2036b11 100644 --- a/dir_73a3cc5065b223eb41b02873c0e19f0e.html +++ b/dir_73a3cc5065b223eb41b02873c0e19f0e.html @@ -116,6 +116,9 @@ Files  brute_force_string_searching.cpp  String pattern search - brute force.
  + duval.cpp + Implementation of Duval's algorithm.
 horspool.cpp  Horspool's algorithm that finds if a string contains a substring (https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm)
  diff --git a/dir_73a3cc5065b223eb41b02873c0e19f0e.js b/dir_73a3cc5065b223eb41b02873c0e19f0e.js index c41a774ef..2effa69ae 100644 --- a/dir_73a3cc5065b223eb41b02873c0e19f0e.js +++ b/dir_73a3cc5065b223eb41b02873c0e19f0e.js @@ -2,6 +2,7 @@ var dir_73a3cc5065b223eb41b02873c0e19f0e = [ [ "boyer_moore.cpp", "d3/db2/boyer__moore_8cpp.html", "d3/db2/boyer__moore_8cpp" ], [ "brute_force_string_searching.cpp", "d3/d7d/brute__force__string__searching_8cpp.html", "d3/d7d/brute__force__string__searching_8cpp" ], + [ "duval.cpp", "db/d09/duval_8cpp.html", "db/d09/duval_8cpp" ], [ "horspool.cpp", "d3/dfe/horspool_8cpp.html", "d3/dfe/horspool_8cpp" ], [ "knuth_morris_pratt.cpp", "de/d6a/knuth__morris__pratt_8cpp.html", "de/d6a/knuth__morris__pratt_8cpp" ], [ "manacher_algorithm.cpp", "d3/d39/manacher__algorithm_8cpp.html", "d3/d39/manacher__algorithm_8cpp" ], diff --git a/doxygen_crawl.html b/doxygen_crawl.html index 3a74cb077..21425dc1d 100644 --- a/doxygen_crawl.html +++ b/doxygen_crawl.html @@ -301,6 +301,7 @@ + @@ -663,6 +664,7 @@ + @@ -743,27 +745,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + @@ -2235,6 +2237,8 @@ + + @@ -3038,6 +3042,10 @@ + + + + @@ -4104,6 +4112,27 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/files.html b/files.html index 0944e54f5..b14d3a9e6 100644 --- a/files.html +++ b/files.html @@ -418,11 +418,12 @@ N)\) time, with precision fixed using   strings  boyer_moore.cppThe Boyer–Moore algorithm searches for occurrences of pattern P in text T by performing explicit character comparisons at different alignments. Instead of a brute-force search of all alignments (of which there are n - m + 1), Boyer–Moore uses information gained by preprocessing P to skip as many alignments as possible  brute_force_string_searching.cppString pattern search - brute force - horspool.cppHorspool's algorithm that finds if a string contains a substring (https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm) - knuth_morris_pratt.cppThe Knuth-Morris-Pratt Algorithm for finding a pattern within a piece of text with complexity O(n + m) - manacher_algorithm.cppImplementation of Manacher's Algorithm - rabin_karp.cppThe Rabin-Karp Algorithm for finding a pattern within a piece of text with complexity O(n + m) - z_function.cppThe Z function for finding occurences of a pattern within a piece of text with time and space complexity O(n + m) + duval.cppImplementation of Duval's algorithm + horspool.cppHorspool's algorithm that finds if a string contains a substring (https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm) + knuth_morris_pratt.cppThe Knuth-Morris-Pratt Algorithm for finding a pattern within a piece of text with complexity O(n + m) + manacher_algorithm.cppImplementation of Manacher's Algorithm + rabin_karp.cppThe Rabin-Karp Algorithm for finding a pattern within a piece of text with complexity O(n + m) + z_function.cppThe Z function for finding occurences of a pattern within a piece of text with time and space complexity O(n + m) diff --git a/globals_func_m.html b/globals_func_m.html index 2553d7c76..4dd74efe7 100644 --- a/globals_func_m.html +++ b/globals_func_m.html @@ -107,7 +107,7 @@ $(function(){initNavTree('globals_func_m.html',''); initResizable(true); });
Here is a list of all documented functions with links to the documentation:

- m -