Recall & Review
beginner
What is a Trie node and what does it typically store?
A Trie node is a building block of a Trie data structure. It typically stores an array or map of child nodes for each possible character and a boolean flag to mark if the node represents the end of a word.
Click to reveal answer
beginner
How do you initialize a Trie node in C++?
You create a class with a constructor that initializes all child pointers to nullptr and sets the end-of-word flag to false.Click to reveal answer
beginner
Why do we set all child pointers to nullptr during Trie node initialization?
Setting child pointers to nullptr means no children exist yet. It helps to check if a path exists when inserting or searching words.
Click to reveal answer
beginner
What does the 'end of word' flag in a Trie node represent?
It marks that the path from the root to this node forms a complete word stored in the Trie.
Click to reveal answer
beginner
In a Trie node design, how many children pointers are typically used for English lowercase letters?
Usually 26 pointers, one for each lowercase English letter from 'a' to 'z'.
Click to reveal answer
What is the initial value of child pointers in a newly created Trie node?
✗ Incorrect
Child pointers are set to nullptr to indicate no children exist yet.
What does the boolean flag in a Trie node usually indicate?
✗ Incorrect
The boolean flag marks if the node represents the end of a stored word.
How many child pointers does a Trie node for lowercase English letters usually have?
✗ Incorrect
There are 26 lowercase English letters, so 26 child pointers are used.
Which of these is the best data type for child pointers in a Trie node in C++?
✗ Incorrect
Child pointers should be pointers to TrieNode objects.
Why do we need to initialize the 'end of word' flag to false in a Trie node?
✗ Incorrect
Initially, the node does not represent the end of any word, so the flag is false.
Describe how you would design and initialize a Trie node in C++ for storing lowercase English words.
Think about what each node needs to store and how to prepare it for use.
You got /3 concepts.
Explain why initializing child pointers to nullptr and the end-of-word flag to false is important in a Trie node.
Consider what happens if these are not initialized properly.
You got /4 concepts.