Challenge: Find All Words Stored in Trie

If you are given a trie, can you return every word it contains?

Problem Statement #

You have to implement the find_words() function which will return a sorted list of all the words stored in a trie.

Input #

The root node of a trie.

Output #

A sorted list of all the words stored in a trie.

Sample Input #

keys = ["the", "a", "there", "answer", "any",
        "by", "bye", "their", "abc"]

Sample Output #

["a", "abc", "answer", "any", "by", "bye", "the", "their", "there"] // Sorted alphabetically

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy