Here is the basic idea and implementation code.Priority queue:
An example of a tank war
1 structnode2 {3 intX,y,step;4FriendBOOL operator< (node S1,node s2)//This is the base order for the priority queue when defining the struct.5 {6 returnS1.step>S2.step; Small number of steps on a small top heap7 }8 };9priority_queue<node>q; Structure definition description and life method of priority queue
and check the set:
An example of seven-bridge problem
int findx (int x) { if (X!=parent[x]) Parent[x]=findx (Parent[x]); // return parent[x]; // }son: 1 3 8 9 parent: 1 3 8
int Find (int x) { int k,j,r; = x; while (r! = Parent[r]) // r = Parent[r]; = x; while (k! = r) { = parent[k]; = R; = J; } return R; }
Dictionary Treea problem that has been done http://www.cnblogs.com/A-FM/p/5181956.html
Constructs a struct that should have all the pointer fields pointing to all the elements in the next row, and should have the necessary information for that node
1 structnode2 {3 intNumber//the number of times the node acts as a tail node4Node next[ -];//and the rest of the pointer field5 };6 intInsert (Char*a,node *t)7 {8Node *p,*Q;9 intid,i,j,l;Tenp=t;//has opened up space OneL=strlen (a); A for(i=0; i<l;i++) - { -id=a[i]-'a'; the if(P->next[id]==null)//If we don't have this line, - { -q= (node *)malloc(sizeof(node)); -q->sum=0; + for(j=0;j< -; j + +) -q->next[j]=NULL; +p->next[id]=q;//Create a line segment. The other end of the line is already set. A } atP=p->Next[id]; - } -(p->sum) + +; - returnP->sum; -}
tree-like array:
Priority Queue + and check set + Dictionary tree + Tree Array + segment tree + segment Tree Point update + KMP +AC Automaton + scan line