Jenis Linked List :
Deklarasi node :
node = new nama_node;
- Deklarasi Struct :
struct nama_struct {
type_data nama_variable;
nama_struct *nama_pointer_next;
};
- Tambah Depan
Source Code :
if(head == NULL){
head = node;
tail = node;
}else{
node->next = head;
head = node;
}
- Tambah Belakang
Source Code :
if(tail == NULL){
head = node;
tail = node;
}else{
tail->next = node;
tail = node;
}
- Tampilkan
Source Code :
node = head;
while( node != NULL ) {
printf("Data : %type_data", node->variable_data);
node = node->next;
}
- Deklarasi Struct :
struct nama_struct {
type_data nama_variable;
nama_struct *nama_pointer_next;
nama_struct *nama_pointer_prev;
};
- Tambah Depan
Source Code :
if(head == NULL){
head = node;
tail = node;
}else{
node->next = head;
head->prev = node;
head = node;
}
- Tambah Belakang
Source Code :
if(tail == NULL){
head = node;
tail = node;
}else{
tail->next = node;
node->prev = node;
tail = node;
}
- Tampilkan
Source Code :
node = head;
while( node != NULL ) {
printf("Data : %type_data", node->variable_data);
node = node->next;
}