Skip to content

Trie

storing

Level 2 of 3

Also called Prefix tree and Digital tree.

fresh numbers

The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from trie's own run on the numbers shown.

choose one

question 1

An empty trie puts in tree, trek and trim. How many places does it make?

the answer, and why

the answer is D

tree makes 4 places. trek follows t, r and e and makes k, 1 more. trim follows t and r and makes i and m, 2 more. That is 7.

if you chose another

  • That is the visits, every letter followed or made.
  • That is the letters followed, not the places made.
  • That is one word's places; the later words make some too.

new numbers

question 2

An empty trie puts in car, cat, cart and to. How many letters does it follow?

the answer, and why

the answer is C

car follows none. cat follows c and a, 2. cart follows c, a and r, 3. to follows none. That is 5.

if you chose another

  • That is the places made.
  • That is every letter, followed or made, the visits.
  • That counts the words, not the letters.

new numbers

question 3

Which list makes the most places, put into an empty trie?

the answer, and why

the answer is C

tree, trek and trim make 4, then 1, then 2, which is 7. The others make 5, 6 and 4.

if you chose another

  • trek shares tre with tree, so the two make 5.
  • true shares tr with tree, so the two make 6.
  • The second tree follows every letter and makes nothing, so 4.

new numbers