1 / 11

Double Linked List

Double Linked List. Kuliah Struktur Data 9. Kelemahan Single Link List. Data yang dimasukkan selalu ditempatkan di awal, karena pointer Head selalu menunjuk pointer Now Bagaimana untuk menambahkan data secara berurutan (insert order) ..? Hanya dapat melakukan operasi Find First

dougal
Download Presentation

Double Linked List

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Double Linked List Kuliah Struktur Data 9

  2. Kelemahan Single Link List • Data yang dimasukkan selalu ditempatkan di awal, karena pointer Head selalu menunjuk pointer Now • Bagaimana untuk menambahkan data secara berurutan (insert order) ..? • Hanya dapat melakukan operasi Find First • Bagaimana supaya dapat melakukan pencarian pada data tertentu..? • Pointer hanya bergerak satu arah saja

  3. Double Linked List • Memiliki pointer ganda (penunjuk depan = Head & penunjuk belakang = Tail) • Keadaan awal sama dengan single linked list • Insert (35) new(Now) Head=Nil then Head:=Now; Tail:=Now; • Tail menunjuk ke Nil • Isi data 35 Tail^.Next:=Nil; Now^.Elemen:=35;

  4. Double Linked List • Insert (5)..? New(Now); Head <> NIL then Tail^.Next:=Now; Tail:=Now; Tail^.Next:=Nil; Now^.elemen :=5; • Insert (9)..?

  5. Operasi-Operasi pada Double Linked List • Insert After (1) Menambah simpul dibelakang Head:=Nil New(Now); Now^.elemen := 1; Head=Nil then begin Head:=Now; Tail:=Now; Now^.Next:=NIL; Now^.Prev:=NIL; End

  6. Insert After (2) • Menambah simpul dibelakang • New(Now); • Now^.elemen := 2; • Head <> Nil then • begin • Tail^.Next:=Now; Now^.Prev:=Tail; Tail:=Now; Tail^.Next:=Nil; • End

  7. Insert Before • Berguna untuk menambah simpul di depan • Insert Before (3)

  8. Insert Order / Insert at Position • Delete After • Delete Before • Delete at Position

  9. Delete after • Menghapus data yang berada di belakang • Contoh procedure • begin • Now:=Tail; • If Now <> Head Then • begin • Tail:=Now^.Prev; • Tail^.Next:=Nil; • end else • begin • Tail:=NIL; • Head:=NIL; • end; • if now <> NIL then dispose(Now); • end;

  10. Delete before • Menghapus data yang berada di depan • Contoh procedure • Now:=Head; • if Now <> Tail then • begin • head:=Now^.Next; • Head^.Prev:=NIL; • end • else • begin • Tail:=NIL; • Head:=NIL; • end; • if Now <> NIL then dispose(now); • end;

  11. Hapus potition begin bantu1:=now^.prev; bantu2:=now^.next; If bantu1<> nil then bantu1^.next:=bantu2; else bantu2 :=head If bantu2 <> nil then bantu2^.prev:= bantu1; else bantu1:= tail

More Related