Trie additional nodes

Let's say we have a trie that has the following words in it already .

  1. home
  2. house
  3. belated
  4. heated

If we add the following words, how many nodes will be added to the trie?

  1. hose
  2. belt
  3. heal


The answer is 4.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

展豪 張
Aug 29, 2016

For "hose", nodes 's' and 'e' are added, since 'h' and 'o' are already presented (1. home; 2. house).
For "belt", node 't' is added, since "bel" is already presented (3. belated).
For "heal", node 'l' is added, since "hea" is already presented (4.heated).

Ritika Gupta
Jun 2, 2020

2 with hose 1 with belt and 1 with heal . So total 4

Luke Monaco
Apr 24, 2020

The new words add 4 points at which the letter patterns diverge. IE: there is already an 'ho' but no 'hos'. So 's' becomes a new node.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...