Embercode
✕
Tries (C++)Quick quiz

Wildcard search

7 questions. Covers Wildcard search with dots.

Questions 1 to 5 of 7

  1. 1. The dictionary holds bad, dad and mad. Which pattern does NOT match any stored word?
  2. 2. Why must the search try every child at a dot, instead of following just one child?
  3. 3. Using the WordDictionary class from this lesson, this code runs: ``cpp WordDictionary words; for (std::string_view w : {"moon", "mood", "book"}) words.addWord(w); std::cout << std::boolalpha << words.search("moo") << '\n'; `` What does it print?
  4. 4. Using the same class, this code runs: ``cpp WordDictionary fox; for (std::string_view w : {"fox", "fig", "fan"}) fox.addWord(w); std::cout << std::boolalpha << fox.search("f.g") << '\n'; `` What does it print?
  5. 5. Which statement describes the bug in this dot branch? ``cpp static bool searchFrom(const Node* node, std::string_view pattern, std::size_t pos) { if (pos == pattern.size()) return node->isEnd; if (pattern[pos] == '.') { for (const auto& child : node->children) { if (child) return searchFrom(child.get(), pattern, pos + 1); } return false; } // plain-letter case omitted } ``

5 question(s) left on this page.