Pertemuan 5 Circular List Bernadus Anggo Seno Aji
Pertemuan 5 (Circular List) Bernadus Anggo Seno Aji
Outline Pengertian Circular List Insert dan Delete pada Circular List
Circular Linked List Salah satu variasi dari Linked List dimana elemen list terakhir (Last Element) menunjuk/menyambung ke elemen pertama (First Element) L 15 30 40
4 Circular Linked List Circular list biasanya terurut Circular list sangat berguna untuk “Looping” video atau sound. Circular list merupakan batu loncatan untuk implementasi graf. 10/22/2021
5 Directive #define membuat sebuah macro, pengindentifikasi dengan sebuah string dimana akan berasosiasi dengan #define info(P) (P)->info #define next(P) (P)->next #define first(L) ((L). first) 10/22/2021
6 Exercise P First 13 15 25 30 Task : Draw the Pointer Q next(P) R next(First(L))) S next(Q) 10/22/2021
7 Exercise P First 13 15 Task : what is the output? 25 30 Answer Info(Next(p))) Info(Next(next(First(L)))) Info(next(P)) Info(First(L)) 10/22/2021
8 Structure Untuk List dan Elemen sama dengan single linked list yg biasa ADT Create new list Allocation / create new element Perbedaan dalam inserting dan deleting Insert first and last Delete first and last 10/22/2021
9 Insert to Empty List single list circular Algorithm first(L) P next(P) first(L) P L 15 / 10/22/2021
10 Delete the last element single list circular Algorithm P first(L) next(P) Nil first(L) Nil P L 15 P / 10/22/2021
Insert Last 11 single list circular Kamus Q : address P Algoritma /* buat mekanisme Q menunjuk Last Element*/ next(P) first(L) next(Q) P 15 Q L 30 / 50 10/22/2021
Insert First 12 single list circular Kamus L Q : address P Algoritma /* buat mekanisme Q menunjuk Last Element*/ next(P) first(L) next(Q) P first(L) P 15 Q L 30 50 10/22/2021
13 Delete First single list circular Dictionary Q : address Algorithm /* buat mekanisme Q menunjuk Last Element*/ P first(L) next(P) Nil next(Q) first(L) P P L Q L 30 / 50 15
14 Delete Last single list circular Dictionary Q : address Algorithm /* buat mekanisme Q menunjuk elemen sebelum Last Element dan P menunjuk Last Elemen */ next(Q) first(L) next(P) Nil P Q L 30 50 P 15 /
15 Insert After and Delete After Sama dengan single linked list yang biasa 10/22/2021
Question?
- Slides: 16