Tries Data Structure Overview

A trie (derived from retrieval) is a multiway tree data structure used for storing strings over an alphabet. It is used to store a large amount of strings. The pattern matching can be done efficiently using tries.

Different operations in Tries:-

Advantages of Using Tries

  1. In tries the keys are searched using common prefixes. Hence it is faster. The lookup of keys depends upon the height in case of binary search tree.
  2. Tries take less space when they contain a large number of short strings. As nodes are shared between the keys.
  3. Tries help with longest prefix matching, when we want to find the key.