For some time did not write some about the data structure of the program, just the introduction of the algorithm of the course to learn red and black trees, the sense of data structures are almost forgotten, but also to test, and then take to review.
One, C + + implementation of single-linked list
#include <iostream>using namespaceStd;typedefstructlnode{intdata; structLnode *Next;} Lnode,*linklist;voidcreatelist_l (linklist &l,intN{L=NewLnode (); L->next =NULL; Linklist Temp=L; for(inti = n; i >0; --i) {linklist P=NewLnode (); CIN>> p->data; P->next = temp->Next; Temp->next =p; Temp=p; }}voidprintlist_l (linklist &l,intN) {linklist P= l->Next; for(inti =0; I < n; ++i) {cout<< p->data<<Endl;; P= p->Next; }}intMain () {linklist testlnode; intLength =Ten; createlist_l (testlnode,length); printlist_l (testlnode, length);}
This is relatively simple, do not repeat. Follow-up will be added to various data structures.
Single linked list of data structures (C + + implementation)