0
0
DSA Javascriptprogramming~10 mins

Why Trie Exists and What Hash Map Cannot Do for Strings in DSA Javascript - Test Your Knowledge

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to insert a word into the Trie node children.

DSA Javascript
node.children[[1]] = new TrieNode();
Drag options to blanks, or click blank then click option'
Aword
Bchar
Cindex
Dnode
Attempts:
3 left
💡 Hint
Common Mistakes
Using the whole word as a key instead of a single character.
Using the node itself as a key.
2fill in blank
medium

Complete the code to check if the current node has a child for the character.

DSA Javascript
if (!node.children.hasOwnProperty([1])) { return false; }
Drag options to blanks, or click blank then click option'
Aword
Bnode
Cindex
Dchar
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for the whole word instead of a character.
Using an incorrect variable like index.
3fill in blank
hard

Fix the error in the search function to correctly return if a word exists in the Trie.

DSA Javascript
return node.isEndOfWord === [1];
Drag options to blanks, or click blank then click option'
Afalse
Bnull
Ctrue
Dundefined
Attempts:
3 left
💡 Hint
Common Mistakes
Returning false instead of true for end of word.
Returning null or undefined which are incorrect.
4fill in blank
hard

Fill both blanks to complete the prefix search function that returns true if any word starts with the prefix.

DSA Javascript
for (let [1] = 0; [1] < prefix.length; [1]++) {
  let [2] = prefix[[1]];
  if (!node.children.hasOwnProperty([2])) return false;
  node = node.children[[2]];
}
return true;
Drag options to blanks, or click blank then click option'
Ai
Bchar
Cindex
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same variable name for both index and character.
Using incorrect variable names that don't match the code.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each word to its length only if the length is greater than 3.

DSA Javascript
const result = { [1]: [2] for (const [3] of words) if [2] > 3 };
Drag options to blanks, or click blank then click option'
Aword
Bword.length
Dlength
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect variable names or values in the comprehension.
Confusing keys and values.