0

As part of a programming assignment, I've been asked to implement a suffix trie using C++. We are only allowed to implement this using standard C++11 libraries.

My implementation of the suffix trie consisted of a data structure Trie(string T), which constructs a trie for a given string s. The functions in class Trie are the following:

  • Trie::Trie(string T) - constructor: generates the trie.
  • Trie::substring(string s) - boolean: checks whether a string s is a substring of T.
  • Trie::suffix(string s) - boolean: checks whether a string s is a suffix to T.
  • Trie::count(string s) - integer: returns the number of times a substring s appears throughout T (returns 0 if no s does not occur)
  • Trie::longestRepeat() - string: finds the longest substring in T which occurs more than once.
  • Trie::longestSubstring(string S) - string: finds the longest common substring shared by S and T

Other relevant information: The Trie data structure relies on two other data structures - Node and Edge. Each Node has a vector of outgoing_edges which point to other nodes.


How could I go about implementing an additional function, Trie::show() which generates a rendition of the trie? Since C++ has no inbuilt graphing libraries, I assume I'm forced to resort to some sort of ASCII-art type function. How could I go about building this, given the functions above?

Luke Collins
  • 1,433
  • 3
  • 18
  • 36

0 Answers0