Strings

Problem shape

Intermediate
4
8
15
16
23
42
Core idea

Store strings as paths through character nodes.

Step 1 / 5
Problem shape
Current lesson

Trie Insert and Search Lab

Strings Intermediate

Trie Insert and Search

Welcome to the Trie Insert and Search algorithm lab. Store strings as paths through character nodes. Use it when: Use for prefixes, autocomplete, dictionaries, and word search. The time complexity is O(length), and the space complexity is O(total characters). The pseudocode is: node = root for char in word if child missing create it node = child mark node as word end As you practice, track the state that changes and the condition that makes the algorithm stop.

Time

O(length)

Space

O(total characters)

Pseudocode

node = root
for char in word
  if child missing create it
  node = child
mark node as word end
Open deeper structure lesson
1.0x