
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















e m
m e^ m e
− − 1 2 0
1 2 0
14 8
14 10 6
poly_pointer padd(poly_pointer a, poly_pointer b)
{
poly_pointer front, rear, temp; int sum; rear =(poly_pointer)malloc(sizeof(poly_node)); if (IS_FULL(rear)) { fprintf(stderr, “The memory is full\n”); exit(1); } front = rear; while (a && b) { switch (COMPARE(a->expon, b->expon)) {
void attach(float coefficient, int exponent,
poly_pointer *ptr)
{ /* create a new node attaching to the node pointed to by ptr. ptr is updated to point to this new node. / poly_pointer temp; temp = (poly_pointer) malloc(sizeof(poly_node)); if (IS_FULL(temp)) { fprintf(stderr, “The memory is full\n”); exit(1); } temp->coef = coefficient; temp->expon = exponent; (ptr)->next = temp; *ptr = temp;
}
ptr
ptr
avail
avail
temp
Operations in a circular list
int length(pnode ptr) { pnode temp; int count = 0; if (ptr) { temp = ptr; do { count++; temp = temp->next; } while (temp!=ptr); } return count;
}
List length
typedef struct node *pnode; typedef struct node { char data [4]; pnode next; pnode prev; }