Consider a set of possible combinations with order important, e.g.
(1,7,8,-1,6,3,5)
(2,6,1,4,7,-1,5)
......
The problem is: First, create(that's not the issue here) and store such a combination in an appropriate datastructure
Second, when later on one generates a nw combination, search efficiently to see if the combination is among the ones already found.
Possible solutions:
a) serialize , e.g. (1,7,8,-1,6,3,5)->'1,7,8,-1,6,3,5' and store the string;
use a hash table(struct in C) or array to store the string, sort and keep the array sorted. Search might be ineffective
b) create a tree(but not a binary one), where every node is an array pointer, so that at each stage one has to search an array the dimension of the combination
Anyone have a better suggestion?
(1,7,8,-1,6,3,5)
(2,6,1,4,7,-1,5)
......
The problem is: First, create(that's not the issue here) and store such a combination in an appropriate datastructure
Second, when later on one generates a nw combination, search efficiently to see if the combination is among the ones already found.
Possible solutions:
a) serialize , e.g. (1,7,8,-1,6,3,5)->'1,7,8,-1,6,3,5' and store the string;
use a hash table(struct in C) or array to store the string, sort and keep the array sorted. Search might be ineffective
b) create a tree(but not a binary one), where every node is an array pointer, so that at each stage one has to search an array the dimension of the combination
Anyone have a better suggestion?