Declaratii structuri

download Declaratii structuri

of 2

Transcript of Declaratii structuri

  • 8/18/2019 Declaratii structuri

    1/2

    Liste simplu inlantuite:

    R1:

    typedef int Item;

    typedef struct cel {

    Item elem;

    struct cel *next;

    } ListCel, *TList;

    R2:

    typedef struct node *Lin ;

    typedef struct node {

    Item elem;

    Lin next;

    } List!ode;

    Liste du"lu inlantuite:

    typedef struct List!ode {

    struct List!ode *next;

    struct List!ode *pre#;

    T #alue;

    } List!ode;

    typedef struct List {

    List!ode *first;

    List!ode *last;

    } List;

    Co$i:

    typedef struct !ode{ T #alue; struct !ode* next;}!ode;

    typedef struct %ueue{ !ode* front; !ode* rear;}%ueue;

  • 8/18/2019 Declaratii structuri

    2/2

    &ti#e:

    typedef struct !ode

    { T #alue; struct !ode* next;}!ode;

    typedef struct &tac{ !ode* 'ead;

    }&tac ;

    (r"ori "inari:

    typedef int Item;

    typedef struct node {

    Item elem;

    struct node *lt, *rt; } Tree!ode, *TTree;

    (r"ori "inari de cautare:

    typedef struct )&T!ode{

    Item elem;

    struct )&T!ode *p; parent + not really needed, "ut simplifiesimplementation

    struct )&T!ode *l; left c'ild

    struct )&T!ode *r; ri-'t c'ild

    })&T!ode;

    typedef struct )&Tree{

    lon- si$e; T'is inintially is ., and is updated "y insert delete

    )&T!ode *root; T'e sentinel root T'e actual root node is root+/l 0

    )&T!ode *nil; T'e nil sentinel to a#oid c'ec s for ! LL

    })&Tree;