0

How would I ensure I obtain a minimal trie when the order of elements is not important (ie - "abdc" is equivalent to "cbad" for my purposes)? To be clear, minimal means the least possible number of nodes while still maintaining a path for each subset

For example, for "abc" -> 10, "fab" -> 11 and "xbfa" -> 12, i would have something like

a -- b -- c -> 10
     \--- f -> 11
          \--- x -> 12

I have tried some heuristics involving frequency count, but this is essentially a greedy approach. Is there a better way to do this?

Sprite123
  • 9
  • 2

1 Answers1

1

Sticking to frequency count is your best bet here probably

NeedHelp
  • 61
  • 4