Some views on the Experiment 5 The third experiment "competition problem"


After studying the "race problem" experiments, summed personal views about the algorithm.

Since the establishment of the tree is the way the game, so it should start input from the leaf node; if the leaf node seen as the first layer, then up until the tree roots are from the second layer of the leaf nodes twenty-two up screening out, which is the pairwise comparison of the size of the final output.

Well, the details: how to achieve pairwise comparisons?

My idea is to store data by two-dimensional array, that is, is the result of a game each column, two-dimensional array can be compared with each other to achieve more data. The use of the storage list structure, and in order with the use of pointers to structures, which use a two-dimensional array to store what is ordinary array structure or the use of an array of pointers to achieve, I still did not end, after all, especially the pointer array pointer how to use this thing still some awkward, really is an ordinary array comfortable to use, though no pointer with them flexible. Although I chose an array of pointers, but actually with the bad.

Fake code:

1, the game input data, and eleven members impart data structure pointer pointing bt;

2, two-dimensional array initialization pointer (* count) [i] [n] = NULL;

3, the data pointed bt impart dimensional data array pointer ;

// This is the key to using an array of pointers, a pointer, then pass a pointer to a data structure will be more convenient. //

4, if data is stored in a separate array of two lines arrive, increasing the number of columns of the array, return the row index 0, i.e.

if(i<1)
break;
else
{++n;i=0;}

This can facilitate later comparison, the comparison is complete after only a set of data and ++ i ++ n it.

Section is located above the constructor. Because different scenarios title set, it can not be along the lines of the usual first traversal processing, traversed only on the back. I feel more of what in fact is not difficult, the difficulty is how to input data stored for later random use, instead of entering the show before. After each comparing the stored results is necessary and crucial.

Of course, in front of that process it is static, that is, all of the leaf nodes are entered after the start of processing operations achieved. Dynamic operational effects can not make come up.

Guess you like

Origin blog.csdn.net/z1094219402/article/details/41928441