0

I'm writing a Trie structure. How can I find the most frequent prefix of the set length n and the most frequent prefix of the length n or longer?

I've found this code useful to get all the words which start with set prefix.

Roger
  • 69
  • 9
  • 1
    Welcome to StackOverflow ! What did you try ? Using a tree seems to be a good idea here. – Arnaud Denoyelle May 14 '19 at 16:03
  • 1
    Add a counter to the trie nodes. Increment the counter as you build the trie. Then scan the nodes afterwards to examine the counters. – Andreas May 14 '19 at 16:09
  • Yes, it works now :) Thanks – Roger May 14 '19 at 19:00
  • The most frequent prefix of length n or longer is the most frequent prefix of length n, except if you attempt to find the longest prefix among the most frequent prefixes of length n or longer. – m.raynal May 15 '19 at 10:15

0 Answers0