0% found this document useful (0 votes)
23 views12 pages

Binary Tree Operations in C

Uploaded by

Duy Tâm Đào
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views12 pages

Binary Tree Operations in C

Uploaded by

Duy Tâm Đào
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CÂY NHỊ PHÂN

đổi cây nhị phân sang cây phản chiếu createTree


Tree convertTree(Tree T) int preIndex =0;
{ Tree createTree( char pre[], char in[], int start, int end)
if(T==NULL) return NULL; {
Tree tmp = T->Left; Tree N = NULL;
T->Left = T->Right; if(start<=end)
T->Right = tmp; {
convertTree(T->Left); N = (Tree) malloc(sizeof(struct Node));
convertTree(T->Right); N->Data = pre[preIndex];
return T; preIndex++;
} if(start==end)
cây rỗng thì NULL {
gán con trái sang phải, gán con phải sang trái N->Left = NULL;
đệ quy trái phải N->Right = NULL;
return N;
}
int inIndex = findIndex(N->Data, in, start, end);
N->Left = createTree(pre, in, start, inIndex-1);
N->Right= createTree(pre, in, inIndex+1, end);
}
return N;
}

Tree createTree(char pre[], char in[], int Start, int End)


{
static int preIndex =0;
if(Start > End)
return NULL;
Tree node = (Tree)malloc(sizeof(struct Node));
node->Data = pre[preIndex++];
if(Start == End)
{
node->Left = NULL;
node->Right= NULL;
return node;
}
int inIndex = findIndex(node->Data, in, Start, End);
node->Left = createTree(pre,in,Start,inIndex -1);
node->Right = createTree(pre,in,inIndex+1,End);
return node;
}
deleteNode findElement
KeyType Min (Tree *T) Tree findElement(DataType x, Tree T)
{ {
KeyType k; if(T==NULL)
if ((*T)->Left == NULL ) return NULL;
{ if(T->Data==x)
k = (*T)->Key; return T;
(*T) = (*T)->Right; else
return k; {
} if(findElement(x,T->Left) != NULL)
else return findElement(x,T->Left);
return Min(&(*T)->Left); else
} return findElement(x,T->Right);
void deleteNode (int x, Tree *T) }
{ }
if ((*T) != NULL){
if (x < (*T)->Key)
deleteNode(x, &(*T)->Left);
else if (x > (*T)->Key)
deleteNode(x, &(*T)->Right);

else{
if ((*T)->Left==NULL && (*T)-
>Right==NULL)
(*T) = NULL;
else if ((*T)->Left==NULL)
(*T) = (*T)->Right;
else if ((*T)->Right==NULL)
(*T) = (*T)->Left;
else
(*T)->Key = Min(&(*T)-
>Right);
}
}
else printf("Loi: Hang rong!");}

findMax Cây nhị phân/getDiameter.c


char findMax(Tree T) int getHeight(Tree T) {
{ if (T == NULL) return 0;
char max; return max(getHeight(T->Left), getHeight(T->Right)) +
if(T==NULL) {return 0;} 1;
else max = T->Data; }
char Ltree = findMax(T->Left);
char Rtree = findMax(T->Right); void getDiameterHelper(Tree T, int* maxDiameter) {
if (Ltree > max) if (T == NULL) return;
max = Ltree;
if (Rtree > max) int diameter = getHeight(T->Left) + getHeight(T-
max = Rtree; >Right) + 1;
return max; if (diameter > *maxDiameter) {
} *maxDiameter = diameter;
}

getDiameterHelper(T->Left, maxDiameter);
getDiameterHelper(T->Right, maxDiameter);
}

void getDiameter(Tree T, int* diameter) {


*diameter = 0;
getDiameterHelper(T, diameter);
}
tính chiều cao cây +1
Cây nhị phân/getFullNodes.c Cây nhị phân/getHeight- Chiều cao cây.c
int getFullNodes(Tree T) { int height(struct Node* root)
if (T == NULL) {
return 0; if(root == NULL) return -1;
if (T->Left != NULL && T->Right != NULL) else
return 1 + getFullNodes(T->Left) + getFullNodes(T- { return max(height(root->Left),height(root-
>Right); >Right))+1;}
else }
return getFullNodes(T->Left) + getFullNodes(T- Cây nhị phân/getHeight.c
>Right); int getHeight(Tree T)
} {
------------------------------------------------------------- if(T==NULL) return -1;
int getFullNodes(Tree T) { int sL=getHeight(T->Left);
if (T == NULL) { int sR=getHeight(T->Right);
return 0; if(sL>=sR)
} sR=sL;
int count = 0; return sR+1;
if (T->Left != NULL && T->Right != NULL) { }
count++;
}
count += getFullNodes(T->Left) + getFullNodes(T-
>Right);
return count;
}
Cây nhị phân/getParent.c Cây nhị phân/getPrevious.c
Tree getParent (int x, Tree T) Tree getPrevious(int x, Tree T)
{ {
Tree tmp=NULL; Tree tmp = NULL;
while(T!=NULL && T->Key!=x) while(T!=NULL && T->Key !=x)
{ {
tmp=T; if(T->Key > x)
if(x<T->Key) T=T->Left;
T=T->Left; else
else {
T=T->Right; tmp = T;
} T=T->Right;
return tmp; }
} }
if (T->Left == NULL)
return tmp;
else
{
T = T->Left;
return T;
}
}
Cây nhị phân/getnext.c Cây nhị phân/hNode.c
Tree getMin (Tree T){ int getHeight(Tree T)
if (T->Left == NULL){ {
return T; if(T==NULL) return -1;
} int sL=getHeight(T->Left)+1;
else return getMin(T->Left); int sR=getHeight(T->Right)+1;
} return sL>sR ? sL:sR;
}
Tree getNext (int x, Tree T){ int hNode(int x, Tree T)
Tree temp=NULL; {
while (T!=NULL && T->Key!=x){ if(T==NULL) return -1;
if (x < T->Key){ while((T->Left!=NULL || T->Right!=NULL) && T-
temp = T; >Key!=x)
T = T->Left; {
} if(T->Key > x)
else if (x > T->Key) T=T->Left;
T = T->Right; if(T->Key < x)
} T=T->Right;
if (T==NULL) }
return NULL; if(T->Key==x) return getHeight(T);
else { return -1;
if (T->Right==NULL){ }
return temp;
} int getHeight(Tree T)
return getMin(T->Right); {
} if(T==NULL) return -1;
return NULL; int h1=getHeight(T->Left)+1;
} int h2=getHeight(T->Right)+1;
return h1>h2?h1:h2;
}

int hNode(int x, Tree T)


{
if(T==NULL) return -1;
if(T->Key==x) return getHeight(T);
else if(x<T->Key)
return hNode(x, T->Left);
else
return hNode(x, T->Right);
}
Cây nhị phân/inOrder-LNR.c Cây nhị phân/initTree - khởi tạo cây.c
void inOrder(Tree T){ Tree initTree()
if(T != NULL) {
{ Tree T = NULL;
inOrder(T->Left); return T;
printf("%d ", T->Data); }
inOrder(T->Right);
}
}
Cây nhị phân/insertNode.c Cây nhị phân/isEmpty.c
void insertNode(int x, Tree *T){ int isEmpty(Tree T)
if((*T) == NULL){ {
(*T) = (struct Node*)malloc(sizeof(struct return T==NULL;
Node)); }
(*T)->Key = x; Cây nhị phân/isMirrors.c
(*T)->Left = NULL; int isMirrors(Tree T1, Tree T2)
(*T)->Right = NULL; {
} if(T1==NULL && T2==NULL)
else return 1;
if (x < (*T)->Key) if(T1==NULL || T2==NULL)
insertNode(x,&((*T)->Left)); return 0;
else if (x > (*T)->Key) if(T1->Data != T2->Data)
insertNode(x,&((*T)->Right)); return 0;
} return isMirrors(T1->Left, T2->Right) &&
isMirrors(T1->Right, T2->Left);
}
2 thàng NULL thì trả ra 1
1 trong 2 NULL thì ra 0
2 khác nhau thì trả ra 0
trả về đệ quy qua 2 con
Cây nhị phân/khai báo cây.c Cây nhị phân/posOrder - Hậu tự.c
khai báo cây void posOrder(Tree T)
#typedef char DataType; {
struct Node { if(T!=NULL)
DataType Data; {
struct Node *Left,*Right; posOrder(T->Left);
}; posOrder(T->Right);
#typedef struct Node* Tree; printf("%d ",T->Key);
}
}
Cây nhị phân/preOrder-NLR.c Cây nhị phân/printAllPaths.c
void preOrder(Tree T) void printAllPaths(Tree T, DataType path[], int len, int
{ pathlen)
printf("%d ",T->Key); {
if(T->Left!=NULL) if(T == NULL)
preOrder(T->Left); return;
if(T->Right!=NULL) path[len] = T->Data;
preOrder(T->Right); len++;
} if(T->Left == NULL && T->Right == NULL &&
void PreOrder(node_t* root){ len == pathlen+1)
if(root != NULL) printArray(path, len);
{ else
printf("%d ", root->data); {
PreOrder(root->left); printAllPaths(T->Left, path, len, pathlen);
PreOrder(root->right); printAllPaths(T->Right, path, len,
} pathlen);
} }
}
Cây nhị phân/printPath-tìm node và in ra trên Cây nhị phân/printPath.c
đường tìm.c void printPath(int x, Tree T){
void printPath(int x, struct Node* node){ if(T == NULL)
printf("-> Khong thay");
if (node->Key == x) else {
{ printf("%d ", T->Key);
if (node != NULL) if(T->Key == x)
return printf("%d -> Tim thay", node->Key); printf("-> Tim thay");
} else
if(node->Left == NULL && node -> Right == NULL) if(T->Key > x)
{ printPath(x, T->Left);
if (node != NULL) else
return printf("%d -> Khong thay", node->Key); printPath(x, T->Right);
} }
printf("%d ", node->Key); }
if (x < node->Key)
printPath(x, node->Left);
else
printPath(x, node->Right);
}
Cây nhị phân/rightSibling.c Cây nhị phân/searchNode.c
Tree rightSibling(int x, Tree T) Tree searchNode (int x, Tree T)
{ {
Tree tmp = T; while (T!=NULL && T->Key!=x)
if(T == NULL) {
return NULL; if (x < T->Key)
while((T->Left!=NULL || T->Right!=NULL) && T- T=T->Left;
>Key!=x) else if (x > T->Key)
{ T=T->Right;
if(T->Key < x) }
{ return T;
tmp = NULL; }
T = T->Right;
}
if(T->Key > x)
{
tmp = T->Right;
T=T->Left;
}
}
return tmp;
}
DANH SÁCH LIÊN KẾT
DS liên kết/addFirst.c DS liên kết/append.c
void addFirst(ElementType x, List *L) void append(ElementType x, List *L)
{ {
Position P=*L; Position P=*L;
struct Node* t=(struct Node*)malloc(sizeof(struct while(P->Next!=NULL)
Node)); P=P->Next;
t->Element=x; struct Node* t=(struct Node*)malloc(sizeof(struct
t->Next=P->Next; Node));
P->Next=t; t->Element=x;
} t->Next=P->Next;
P->Next=t;
}
DS liên kết/copyEvenNumbers-số chẵn DS liên kết/deleteList.c
L1→L2.c void deleteList(Position p, List *pL)
void copyEvenNumbers(List L1, List *L) {
{ if (p->Next != NULL)
makenullList(L); {
Position A=L1->Next; Position t = p->Next;
while(A!=NULL) p->Next = t->Next;
{ free(t);
if(A->Element%2==0) }
append(A->Element,L); }
A=A->Next;
}
}
DS liên kết/difference.c DS liên kết/erase.c
List difference(List L1, List L2){ void erase(ElementType x, List *L)
List L; {
makenullList(&L); if(locate(x,*L)->Next!=NULL)
Position A=L1->Next; deleteList(locate(x,*L),L);
while(A!=NULL) { else
if(!member(A->Element,L2)) printf("Not found %d\n",x);
append(A->Element,&L); }
A=A->Next; không trả về giá trị nên deleteList không cần &L
} xác định vị trí locate *
return L;}
DS liên kết/getAvg.c DS liên kết/insertList.c
float getAvg(List L) void insertList(ElementType x,Position p, List *L)
{ {
float s; struct Node* t=(struct Node*)malloc(sizeof(struct
int i=0; Node));
if(L->Next==NULL) t->Element=x;
return -10000; t->Next=p->Next;
while(L->Next!=NULL) p->Next=t;
{ }
s+= L->Next->Element;
i++;
L=L->Next;
}
return s/i;
}
DS liên kết/intersection-giao của 2 tập hợp.c DS liên kết/khai báo.c
List intersection(List L1, List L2) khai báo ds lk
{ typedef int ElementType;
List L; struct Node
makenullList(&L); {
Position A=L1->Next; ElementType Element;
while(A!=NULL) struct Node* Next;
{ };
if(member(A->Element,L2)) typedef struct Node* Position;
append(A->Element,&L); typedef Position List;
A=A->Next;
}
return L;
}

member(x,L);
append(x,&L);
DS liên kết/locate.c DS liên kết/maknullList.c
Position locate(ElementType x,List L) void makenullList(List *L)
{ {
Position A=L; (*L) = (struct Node*)malloc(sizeof(struct Node));
while(A->Next!=NULL) (*L)->Next=NULL;
{ }
if(A->Next->Element==x) DS liên kết/member.c
break; int member(ElementType x, List L)
else {
A=A->Next; Position A=L->Next;
} while(A!=NULL)
return A; {
} if(A->Element==x)
return 1;
A=A->Next;
}
return 0;
}
DS liên kết/normalize.c DS liên kết/printOddNumbers.c
void normalize(List *L) void printOddNumbers(List L)
{ {
Position A,B; Position P=L->Next;
A=*L; while(P!=NULL)
while (A->Next!=NULL) {
{ if(P->Element%2!=0)
B=A->Next; printf("%d ",P->Element);
while(B->Next!=NULL) P=P->Next;
{ }
if(A->Next->Element == B->Next->Element) }
deleteList(B,L);
else
B=B->Next;
}
A=A->Next;
}
}
DS liên kết/readList.c DS liên kết/readSet.c
void append(ElementType x, List *L) List readSet()
{ {
Position A=(*L); List L;
while(A->Next!=NULL) makenullList(&L);
A=A->Next; int n,x;
struct Node* t=(struct Node*)malloc(sizeof(struct scanf("%d",&n);
Node)); for(int i=0; i<=n; i++)
t->Element=x; {
t->Next=A->Next; scanf("%d",&x);
A->Next=t; if(!member(x,L))
} addFirst(x,&L);
void readList(List *L) }
{ return L;
makenullList(L); }
int n,x; DS liên kết/removeAll.c
scanf("%d",&n);
for(int i=0; i<n;i++) void removeAll(ElementType x, List *L)
{ {
scanf("%d",&x); while(locate(x,*L)->Next!=NULL)
append(x,L); {
} deleteList(locate(x,*L),L);
} }
}
DS liên kết/unionSet.c DS liên kết/sort-sắp xếp danh sách tăng dần.c
List unionSet(List L1, List L2) void sort(List *L)
{ {
List L; Position A=*L;
makenullList(&L); while(A->Next!=NULL)
Position P = L1; {
while (P->Next != NULL) Position B=A->Next;
{ while(B->Next!=NULL)
append(P->Next->Element, &L); {
P = P->Next; if(A->Next->Element>B->Next->Element)
} {
P = L2; ElementType tmp=A->Next->Element;
while (P->Next != NULL) A->Next->Element=B->Next->Element;
{ B->Next->Element=tmp;
if (!member(P->Next->Element, L)) }
append(P->Next->Element, &L); B=B->Next;
P = P->Next; }
} A=A->Next;
return L; }
} }
DANH SÁCH ĐẶC
Danh sách đặc/copyEvenNumbers-chèn số Danh sách đặc/dathuc.c
chẳn L1 vào L2.c void inDaThuc(DaThuc d){
void copyEvenNumbers(List L1, List *L2) Position p=d;
{ while(p->Next!=NULL){
makenullList(L2); if (p->Next->Next==NULL)
for(int i=0; i<[Link]; i++) printf("%.3fX^%d",p->Next-
{ >e.he_so,p->Next->[Link]);
if([Link][i]%2==0) else
insertList([Link][i],L2->Last+1,L2); printf("%.3fX^%d + ",p->Next-
} >e.he_so,p->Next->[Link]);
} p=p->Next;
}
Danh sách đặc/deleteList.c printf("\n");
void deleteList(int p, List *pL) }
{ DaThuc tinhDaoHam(DaThuc D){
if(p<1||p>pL->Last) DaThuc dt;
printf("Vi tri khong hop le \n"); DonThuc e;
else dt=khoitao();
{ Position p=D;
for(int i=p-1; i<pL->Last; i++) while(p->Next!=NULL){
{ e=p->Next->e;
pL->Elements[i]=pL->Elements[i+1]; e.he_so *= [Link];
} [Link]--;
pL->Last--; chenDonThuc(e,&dt);
} p=p->Next;
} }
Danh sách đặc/erase-xoá phần tử đầu tiên.c return dt;
void erase(int x, List *pL) }
{ DaThuc nhanDaThuc(DaThuc D1, DaThuc D2){
deleteList(locate(x,*pL),pL); DaThuc d;
} DonThuc e,temp;
deleteList(int x, List L) d=khoitao();
locate(int, List *pL) không thấy trả về L->Last+1 Position q,p;
Danh sách đặc/getAvg.c p=D1;
float getAvg(List L) while (p->Next!=NULL){
{ e=p->Next->e;
float s=0; q=D2;
for (int i=0; i<[Link]; i++) while (q->Next!=NULL){
{ temp.he_so = e.he_so * q->Next-
s+=[Link][i]; >e.he_so;
} [Link] = [Link] + q->Next-
if([Link]==0) >[Link];
return -10000; chenDonThuc(temp,&d);
return s/[Link]; q=q->Next;
} }
p=p->Next;
}
return d;
}
Danh sách đặc/ds sinh viên.c Danh sách đặc/hiệu của A so với B.c
List getList(){ #include "stdio.h"
List L; #include "math.h"
L=(struct Node*)malloc(sizeof(struct Node)); #include "AListLib.c"
L->Next=NULL;
return L; int member(int x, List L)
} {
typedef struct for(int i=0; i<[Link]; i++)
{ {
char ID[10]; if([Link][i]==x)
char Name[50]; return 1;
float R1, R2, R3; }
}Student; return 0;
}
struct Node void readList(List *L)
{ {
Student Element; makenullList(L);
struct Node* Next; int n;
}; scanf("%d",&n);
for (int i=0; i<n; i++)
typedef struct Node* List; {
int append(Student s, List *pL){ scanf("%d",&L->Elements[i]);
struct Node *P, *temp; if(!member(L->Elements[i],*L))
P=locate([Link],(*pL)); insertList(L->Elements[i],L->Last+1,L);
if (P->Next!=NULL){ }
return 0; }
} void Even(List L1, List L2)
else{ {
temp=(struct Node*)malloc(sizeof(struct int count=0;
Node)); for(int i=0; i<[Link];i++)
temp->Element=s; {
temp->Next=NULL; count=0;
P->Next=temp; for(int z=0; z<[Link]; z++)
return 1; {
} if([Link][i]==[Link][z])
} count++;
Danh sách đặc/insertList.c }
void insertList(int X, Position P, List *L) if(count ==0)
{ printf("%d ",[Link][i]);
if ((P < 1) || (P > L->Last + 1)) }
printf("Vi tri khong hop le"); }
else void printList(List L)
{ {
Position Q; /*Dời các phtử từ vị for (int i=0; i<[Link]; i++)
trí p đến cuối dsách ra sau 1 vị trí*/ {
for (Q = L->Last+1; Q > P; Q--) printf("%d ", [Link][i]);
L->Elements[Q] = L->Elements[Q - 1]; // Đưa x }
vào vị trí p printf("\n");
L->Elements[P - 1] = X; // Tăng độ dài }
danh sách lên 1 int main()
L->Last++; {
} List L1,L2,L;
} makenullList(&L);
Danh sách đặc/in 2 tập hơp.c readList(&L1);
#include "stdio.h" printList(L1);
#include "math.h" readList(&L2);
#include "AListLib.c" printList(L2);
Even(L1,L2); }
int member(int x, List L) Danh sách đặc/insertSet-chèn phần tử vào
{ cuối.c
for(int i=0; i<[Link]; i++) void insertSet(int x, List *pL)
{ {
if([Link][i]==x) pL->Elements[pL->Last]=x;
return 1; pL->Last++;
} }
return 0; Danh sách đặc/intersection-hợp của 2 tập hơp.c
} void intersection(List L1, List L2, List *pL)
void readList(List *L) {
{ makenullList(pL);
makenullList(L); for (int i=0; i<[Link]; i++)
int n; {
scanf("%d",&n); if(member([Link][i],L2))
for (int i=0; i<n; i++) insertSet([Link][i],pL);
{ }
scanf("%d",&L->Elements[i]); }
if(!member(L->Elements[i],*L)) makenullList(List *pL)
insertList(L->Elements[i],L->Last+1,L); member(ElementType x, List L)
} insertSet(ElementType x, List *pL)
} Danh sách đặc/khai báo mảng.c
void Even(List L1, List L2) #define MaxLength 100 //Độ dài tối đa ds
{ typedef int ElementType; //kiểu của phtử
for(int i=0; i<[Link]; i++) typedef int Position; //kiểu vị trí
{printf("%d ",[Link][i]);} typedef struct
for(int i=0; i<[Link];i++) { //mảng chứa các
{ phần tử của danh sách
int count=0; ElementType Elements[MaxLength];
for(int z=0; z<[Link]; z++) Position Last; //giữ độ dài danh sách
{ }List;
if([Link][i]==[Link][z]) Danh sách đặc/locate.c
count++; int locate(int x, List L)
} {
if(count==0) int p=0;
printf("%d ",[Link][i]); for(int i=0; i<[Link]; i++)
} {
} if([Link][i]==x)
void printList(List L) return p=i+1;
{ }
for (int i=0; i<[Link]; i++) return p=[Link]+1;
{ }
printf("%d ", [Link][i]); Danh sách đặc/makenullList trỏ đến Last=0.c
} void makenullList(List *pL)
printf("\n"); {
} pL->Last=0;
int main() }
{ Danh sách đặc/normalize.c
List L1,L2,L; void normalize(List *L)
makenullList(&L); {
readList(&L1); Position a, b;
printList(L1); a = 1;
readList(&L2); while (a != L->Last + 1)
printList(L2); {
Even(L1,L2); } b = a + 1;
Danh sách đặc/printOddNumber.c while (b != L->Last + 1) {
void printOddNumbers(List L) if (L->Elements[a - 1] == L->Elements[b - 1])
{ {deleteList(b, L);}
for (int i = 0; i < [Link]; i++) else
{ {b++;}
if ([Link][i] % 2 != 0) }
printf("%d ", [Link][i]); a++;
} }}
} Danh sách đặc/readSet.c
Danh sách đặc/readList.c void readSet(List *pL)
{
void readList(List *pL) makenullList(pL);
{ int n;
makenullList(pL); scanf("%d",&n);
int n; for(int i=0; i<n; i++)
scanf("%d",&n); {
for (int i=0; i<n; i++) scanf("%d",&pL->Elements[i]);
{ if(!member(pL->Elements[i],*pL))
scanf("%d",&pL->Elements[i]); {
insertList(pL->Elements[i],i+1,pL); insertSet(pL->Elements[i],pL);
} }
} }
Danh sách đặc/removeAll-Xoá giá trị trong L.c }
void removeAll(ElementType X, List *pL) makenullList(List *pL)
{ member(ElementType x, List L)
while(locate(X,*pL)!=pL->Last+1) insertSet(ElementType x, List *pL)
{ Danh sách đặc/sort.c
int P=locate(X,*pL); void sort(List *pL)
deleteList(P, pL); {
} int s;
} for(int i=0; i<pL->Last; i++)
locate không thấy trả ra Last+1 {
Danh sách đặc/sochan.c for(int z=i+1;z<pL->Last;z++)
void copyEvenNumbers(List L1, List *pL2) {
{ if(pL->Elements[i]>pL->Elements[z])
makenullList(pL2); {
for(int i=0;i<[Link];i++) s = pL->Elements[z];
{ pL->Elements[z]=pL->Elements[i];
if([Link][i]%2==0) pL->Elements[i]=s;
insertList([Link][i],pL2->Last+1,pL2); }
} }
} }
Danh sách đặc/sole.c }
void unionSet(List L1, List L2, List *L)
{
makenullList(L);
for(int i=0; i<[Link]; i++)
{
insertList([Link][i],L->Last+1,L);
}
for(int i=0; i<[Link]; i++)
{
if(!member([Link][i],L1))
insertList([Link][i],L->Last+1,L);
}
}

You might also like