With the following Trie Struct:
struct Trie{
    char letter;
    bool eow;
    Trie *letters[26];
};
I'm using the following code to extract words from a trie into a vector in alphabetic order.
void getWords(const TrieNode& data, vector<string> &words, string acc)
{
  if (data.eow)
    words.push_back(acc);
  for (int i = 0; i < 26; i++) {
    if (data.letters[i] != NULL)
      getWords(*(data.letters[i]), words, acc + data.letters[i]->letter);
  }
}
I was just wondering if there was a way to do this without recursion, and using only iteration? I'm trying to implement this with only iteration, but can't think of a way to check every letter of each layer in the trie, using loops. Any suggestions?
 
    