I have some sequences as these

(100) - (102) - (103) - (104,106) - (108)
(101) - (103)
(102) - (106)

there is some efficient implementation an prefix tree or fp-tree or similar in C + +?

有帮助吗?

解决方案

I don't understand what are you saying... But if you need to build a FP tree here is best page I've found

FP Tree Algorithm

其他提示

It's not clear exactly what you have because the given data doesn't appear to be in any standard notation.

If the prefixes are just a few shared initial decimal digits between integer values, they probably won't make any significant difference to data storage. You could subtract 100 before inserting values into the data structure, store the values as char, and add 100 back after retrieval, but it's probably not worth the effort.

Probably you should store the sequence of sequences as a std::deque< std::vector< int > > where the vector elements are sorted. Unless there is a pattern that I can't see or I'm misinterpreting the problem, optimal performance in finding which sequences contain a given number must be O(N) in the number of sequences times O(lg N) in the sequence length.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top