Given the TAD LIST_ENC_NC_ORD , I need to implement an operation that takes two lists and returns a list resulting from their concatenation, and can not have elements of same value.
Here the TAD:
typedef struct nodo
{
int inf;
struct nodo * next;
}NODO;
typedef NODO * LISTA_ENC_NC_ORD;
It is chained, ordered incrementally, and has a header node (the node is a NODO too, but the inf field is the number of elements in the list, and the next one is the first element). >
The operation:
LISTA_ENC_NC_ORD concatenar (LISTA_ENC_NC_ORD l1, LISTA_ENC_NC_ORD l2)
Insert operation:
void ins (LISTA_ENC_NC_ORD l, int val)
{
NODO *novo, *aux;
novo=(NODO *)malloc(sizeof(NODO));
if (!novo)
{
printf ("erro! memoria insuficiente");
exit(2);
}
for (aux=l; aux->next!=NULL && val>(aux->next)->inf; aux=aux->next);
novo->inf = val;
novo->next = aux->next;
aux->next = novo;
l->inf++;
}
I can not do it at all, if someone helps me I'll be very grateful ^^