Dalam tutorial ini, anda akan mempelajari pelbagai jenis senarai terpaut. Anda juga akan dapat melihat pelaksanaan senarai terpaut di C.
Sebelum anda mengetahui mengenai jenis senarai yang dipautkan, pastikan anda mengetahui mengenai Struktur Data LinkedList.
Terdapat tiga jenis Senarai Berkaitan yang biasa.
- Senarai Terhubung Sendiri
- Senarai Berganda Berganda
- Senarai Berkaitan Pekeliling
Senarai Terhubung Sendiri
Ia adalah yang paling biasa. Setiap nod mempunyai data dan penunjuk ke simpul seterusnya.

Node ditunjukkan sebagai:
struct node ( int data; struct node *next; )
Senarai tiga anggota yang dipautkan secara tunggal boleh dibuat sebagai:
/* Initialize nodes */ struct node *head; struct node *one = NULL; struct node *two = NULL; struct node *three = NULL; /* Allocate memory */ one = malloc(sizeof(struct node)); two = malloc(sizeof(struct node)); three = malloc(sizeof(struct node)); /* Assign data values */ one->data = 1; two->data = 2; three->data = 3; /* Connect nodes */ one->next = two; two->next = three; three->next = NULL; /* Save address of first node in head */ head = one;
Senarai Berganda Berganda
Kami menambah penunjuk ke simpul sebelumnya dalam senarai berganda. Oleh itu, kita boleh pergi ke arah mana pun: ke hadapan atau ke belakang.

Node ditunjukkan sebagai
struct node ( int data; struct node *next; struct node *prev; )
Senarai tiga anggota yang mempunyai dua kaitan boleh dibuat sebagai
/* Initialize nodes */ struct node *head; struct node *one = NULL; struct node *two = NULL; struct node *three = NULL; /* Allocate memory */ one = malloc(sizeof(struct node)); two = malloc(sizeof(struct node)); three = malloc(sizeof(struct node)); /* Assign data values */ one->data = 1; two->data = 2; three->data = 3; /* Connect nodes */ one->next = two; one->prev = NULL; two->next = three; two->prev = one; three->next = NULL; three->prev = two; /* Save address of first node in head */ head = one;
Senarai Berkaitan Pekeliling
Senarai terpaut bulat adalah variasi senarai terpaut di mana elemen terakhir dihubungkan dengan elemen pertama. Ini membentuk gelung bulat.

Senarai pautan pekeliling boleh dipautkan secara tunggal atau dua kali ganda.
- untuk senarai yang dipautkan secara tunggal, penunjuk item terakhir seterusnya menunjukkan item pertama
- Dalam senarai yang dihubungkan dua kali, penunjuk item pertama menunjuk ke item terakhir juga.
Satu senarai pekeliling tiga anggota yang berangkai boleh dibuat sebagai:
/* Initialize nodes */ struct node *head; struct node *one = NULL; struct node *two = NULL; struct node *three = NULL; /* Allocate memory */ one = malloc(sizeof(struct node)); two = malloc(sizeof(struct node)); three = malloc(sizeof(struct node)); /* Assign data values */ one->data = 1; two->data = 2; three->data = 3; /* Connect nodes */ one->next = two; two->next = three; three->next = one; /* Save address of first node in head */ head = one;