Embercode
✕
Tries (C++)Quick quiz

Suffix tries

6 questions. Covers Suffix trie for substring queries.

Questions 1 to 5 of 6

  1. 1. Which rule decides whether a pattern is a substring of a text, in the suffix trie lesson?
  2. 2. A query such as count("ana") walks the pattern through the trie. What does the cost of one query depend on?
  3. 3. What does this program print? ``cpp #include <iostream> #include <string> using namespace std; int main() { string text = "banana"; for (size_t i = 0; i < text.size(); ++i) { if (text[i] == 'n') cout << text.substr(i) << endl; } } ``
  4. 4. What does this program print? ``cpp #include <iostream> #include <string> using namespace std; int main() { string text = "aaaa"; string pattern = "aaa"; int hits = 0; for (size_t i = 0; i + pattern.size() <= text.size(); ++i) { if (text.compare(i, pattern.size(), pattern) == 0) ++hits; } cout << hits << endl; } ``
  5. 5. How many nodes does the suffix trie for banana have, counting the root? Give the number.

    Type a number.

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.