문제

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