Skip to content

Latest commit

 

History

History

LinkedList

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Linked List

Jenis Linked List :

Deklarasi node :

node = new nama_node;

Single Linked List

  • Deklarasi Struct :
struct nama_struct {
    type_data nama_variable;
    nama_struct *nama_pointer_next;
};
  • Tambah Depan

screen

Source Code :

if(head == NULL){
    head = node;
    tail = node;
}else{
    node->next = head;
    head = node;
}
  • Tambah Belakang

screen

Source Code :

if(tail == NULL){
    head = node;
    tail = node;
}else{
    tail->next = node;
    tail = node;
}
  • Tampilkan

screen

Source Code :

node = head;
while( node != NULL ) {
    printf("Data : %type_data", node->variable_data);
    node = node->next;
}

Double Linked List

  • 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

screen

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;
}