Priority Queue + and check set + Dictionary tree + Tree Array + segment tree + segment Tree Point update + KMP +AC Automaton + scan line

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.