Professional Documents
Culture Documents
Nama Kelompok 5
1
KELOMPOK 5 (Chapter 6: LINKED STRUCTURES)
Single Linked List (SLLC) is a linked list that has only one pointer
variable. Where the pointer points to the next node. Usually the tail field
points to NULL.
Definition:
2
KELOMPOK 5 (Chapter 6: LINKED STRUCTURES)
• Single: means that the field pointer is only one and one direction.
• Linked List: means that the nodes are connected to each other.
• Circular: means that the next pointer will point to itself so that it rotates
Example :
Ilustrasi SLLC :
Each node in the linked list has a field that contains a pointer to the
next node, and also has a field that contains data.
At the end of the linked list, the last node points to the leading node so
that the linked list rotates.
int data;
3
KELOMPOK 5 (Chapter 6: LINKED STRUCTURES)
TNode * next;
};
Ilustrasi SLLC :
4
KELOMPOK 5 (Chapter 6: LINKED STRUCTURES)
Setiap node pada linked list mempunyai field yang berisi pointer ke
node berikutnya, dan juga memiliki field yang berisi data.
Pada akhir linked list, node terakhir akan menunjuk ke node terdepan
sehingga linked list tersebut berputar.
struct Student {
char name [25];
int age;
struct Student * next, * prev;
} * head, * tail;
5
KELOMPOK 5 (Chapter 6: LINKED STRUCTURES)
contoh codingannya :
struct Mahasiwa{
char nama[25];
int usia;
struct Mahasiswa *next,*prev;
}*head,*tail;
C. Circular Linked List
It is a linked list where tail (last node) points to head (first node). So
there is no pointer that points to NULL. There are 2 types of Circular Linked
List, namely:
C. Circular Linked List
Merupakan suatu linked list dimana tail (node terakhir) menunjuk ke
head (node pertama). Jadi tidak ada pointer yang menunjuk NULL. Ada 2
jenis Circular Linked List, yaitu :
6
KELOMPOK 5 (Chapter 6: LINKED STRUCTURES)
7
KELOMPOK 5 (Chapter 6: LINKED STRUCTURES)
4. Priority Queue
Priority Queue is similar to the regular queue which was described in the previously
posted Array, Pointer and Data Structure. It's just that this queue is sorted by priority.
For example, we want to create a queue based on age from youngest to oldest. Then
age becomes a priority. Arranging these nodes may be similar to sorting.
• Prefix is a writing method by placing the operator in front of the operand and
without brackets.
Examples of using a prefix are + AB, - + ABC, * + AB - CD.
8
KELOMPOK 5 (Chapter 6: LINKED STRUCTURES)
4. Priority Queue
Priority Queue mirip dengan queue biasa yang telah dijelaskan pada Array,
Pointer dan Struktur Data yang dipost sebelumnya. Hanya saja queue ini di urutkan
berdasarkan prioritasnya. Misalnya kita ingin membuat queue berdasarkan umur yang
paling muda ke tua. Maka umur menjadi prioritas. Penyusunan node ini mungkin
mirip seperti sorting.
Prefix adalah metode penulisan dengan meletakkan operator di depan operand
dan tanpa menuliskan tanda kurung.
Contoh pemakaian prefix adalah +AB, – +ABC, * + AB – CD.
Infix adalah cara penulisan ungkapan dengan meletakkan operator di antara dua
operanddalam hal ini pemakaian tanda kurung sangat menentukan hasil operasi.
Contoh pemakaian infix adalah A+B, A+B-C, (A+B)*(C-D).
Postfix adalah metode penulisan dengan menuliskan operator setelah operand dan
tanpa menuliskan tanda kurung.
9
KELOMPOK 5 (Chapter 6: LINKED STRUCTURES)
d. Find Next
This function looks for the element after the element pointed to now.
e. Retrieve
This function takes the element pointed to by now. The element is then returned
by the function.
f. Update
This function changes the element pointed to by now with the content of
something.
g. Delete Now
This function removes the element pointed to by now. If you delete the first
element of the linked list (head), head will move to the next element.
h. Delete Head
This function removes the element the head points to. The head moves to the next
element.
i. Clear
This function deletes an existing linked list. This function is mandatory if you
want to end a program that uses a linked list. If you do this, the data that was
allocated to the memory in the previous program will remain in the memory.
10
KELOMPOK 5 (Chapter 6: LINKED STRUCTURES)
Fungsi ini mengambil elemen yang ditunjuk oleh now. Elemen tersebut lalu
dikembalikan oleh fungsi.
f) Update
Fungsi ini mengubah elemen yang ditunjuk oleh now dengan isi dari sesuatu.
g) Delete Now
Fungsi ini menghapus elemen yang ditunjuk oleh now. Jika yang dihapus adalah
elemen pertama dari linked list (head), head akan berpindah ke elemen berikutnya.
h) Delete Head
Fungsi ini menghapus elemen yang ditunjuk head. Head berpindah ke elemen
sesudahnya.
i) Clear
Fungsi ini menghapus linked list yang sudah ada. Fungsi ini wajib dilakukan bila
anda ingin mengakhiri program yang menggunakan linked list. Jika anda
melakukannya, data-data yang dialokasikan ke memori pada program sebelumnya
akan tetap tertinggal di dalam memori.
6. Differences Array with Linked List
A. ARRAY
Variable of type array is a data type that is static (order and size is certain). The
disadvantage of static arrays is that the used memory space cannot be deleted if the
array variable names are no longer used in a program (cause of redundancy). To solve
it, dynamic data structures are used using dynamic variables. Dynamic variables
cannot be declared explicitly like static variables and cannot be designated by
identifiers directly, but can be designated specifically by dynamic variables, namely
POINTER.
B. LINKED LIST
This structure consists of a series of interconnected / related elements, where each
element is connected to other elements by a pointer.
11
KELOMPOK 5 (Chapter 6: LINKED STRUCTURES)
Pointer, a cell whose value is the address of another cell where the other cell can
be data or a pointer as well
Every element in the linked list always contains a pointer
B. LINKED LIST
Struktur ini terdiri dari rangkaian elemen yang saling berhubungan / berkaitan,
dimana setiap elemen dihubungkan dengan elemen lainnya oleh sebuah pointer.
Pointer, sel yang nilainya merupakan alamat sel yang lain dimana sel yang lain itu
dapat berupa data atau berupa pointer juga
Setiap elemen dalam linked list selalu berisi pointer
12
KELOMPOK 5 (Chapter 6: LINKED STRUCTURES)
Nil / Null, not valuable, that is, states do not refer to any address.
End, a node that points to the last node
13