summaryrefslogtreecommitdiffstats
path: root/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree
diff options
context:
space:
mode:
Diffstat (limited to '04-algorithms_on_strings/01-suffix_trees/04-suffix_tree')
-rw-r--r--04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/suffix_tree.cpp30
-rw-r--r--04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample11
-rw-r--r--04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample1.a2
-rw-r--r--04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample21
-rw-r--r--04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample2.a5
-rw-r--r--04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample31
-rw-r--r--04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample3.a12
7 files changed, 52 insertions, 0 deletions
diff --git a/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/suffix_tree.cpp b/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/suffix_tree.cpp
new file mode 100644
index 0000000..5d9e2f1
--- /dev/null
+++ b/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/suffix_tree.cpp
@@ -0,0 +1,30 @@
+#include <iostream>
+#include <map>
+#include <string>
+#include <vector>
+
+using std::cin;
+using std::cout;
+using std::endl;
+using std::map;
+using std::string;
+using std::vector;
+
+// Build a suffix tree of the string text and return a vector
+// with all of the labels of its edges (the corresponding
+// substrings of the text) in any order.
+vector<string> ComputeSuffixTreeEdges(const string& text) {
+ vector<string> result;
+ // Implement this function yourself
+ return result;
+}
+
+int main() {
+ string text;
+ cin >> text;
+ vector<string> edges = ComputeSuffixTreeEdges(text);
+ for (int i = 0; i < edges.size(); ++i) {
+ cout << edges[i] << endl;
+ }
+ return 0;
+}
diff --git a/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample1 b/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample1
new file mode 100644
index 0000000..09574e8
--- /dev/null
+++ b/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample1
@@ -0,0 +1 @@
+A$
diff --git a/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample1.a b/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample1.a
new file mode 100644
index 0000000..29f8526
--- /dev/null
+++ b/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample1.a
@@ -0,0 +1,2 @@
+$
+A$
diff --git a/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample2 b/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample2
new file mode 100644
index 0000000..e73cda6
--- /dev/null
+++ b/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample2
@@ -0,0 +1 @@
+ACA$
diff --git a/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample2.a b/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample2.a
new file mode 100644
index 0000000..e374793
--- /dev/null
+++ b/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample2.a
@@ -0,0 +1,5 @@
+$
+CA$
+A
+$
+CA$
diff --git a/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample3 b/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample3
new file mode 100644
index 0000000..cd7fdc4
--- /dev/null
+++ b/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample3
@@ -0,0 +1 @@
+ATAAATG$
diff --git a/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample3.a b/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample3.a
new file mode 100644
index 0000000..2a60baa
--- /dev/null
+++ b/04-algorithms_on_strings/01-suffix_trees/04-suffix_tree/tests/sample3.a
@@ -0,0 +1,12 @@
+$
+T
+G$
+AAATG$
+G$
+A
+T
+G$
+AAATG$
+A
+TG$
+ATG$