Matakuliah Tahun Versi : T0026/Struktur Data : 2005 : 1/1 Pertemuan 4 Doubly Linked List 1 Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : • Mahasiswa dapat menghasilkan program modular dengan doubly linked list 2 Outline Materi • • • • • • Pengertian doubly linked list Deklarasi node doubly LL Operasi-operasi doubly linked list contoh program doubly linked list insert data dalam doubly LL delete data dalam doubly LL 3 Abstract Model of a List Object front back 4 Circular Doubly Linked Lists • Implemented on a Computer it might look something like this. 3 2 4 9 header The 4 node is the front() node & the 2 node is the back() node begin() returns an iterator to the 4 node end() returns an iterator to he header node 5 Updating a Doubly Linked List Before Insert: Empty list prev next header After Iinsert: List with one element prev next header newNode 6 Inserting a Node at a Position next 1 prevNode = curr->prev 3 prev prev 2 item 4 curr next newNode // insert newNode before curr newNode->prev = curr->prev; newNode->next = curr; curr->prev->next = newNode; curr->prev = newNode; 7 Deleting a Node at a Position 1 // // next //// prev prevNode = curr->prev curr succNode = curr->next 2 // unlink the node (*curr) from the list curr->prev->next = curr->next; curr->next->prev = curr->prev; delete curr; 8 Deleting a Node at a Position 1 // // prev prevNode = curr->prev next // // succNode = curr->next curr 2 // unlink the node (*curr) from the list curr->prev->next = curr->next; curr->next->prev = curr->prev; delete curr; 9 Main Index Contents 9
© Copyright 2026 Paperzz