Linked List First Link Data next Null Linked









![Link. List. App class Link. List. App { public static void main(String[] args) { Link. List. App class Link. List. App { public static void main(String[] args) {](https://slidetodoc.com/presentation_image_h/c6dc22bb4168989706728943e26eb87e/image-10.jpg)










![class First. Last. App { public static void main(String[] args) { First. Last. List class First. Last. App { public static void main(String[] args) { First. Last. List](https://slidetodoc.com/presentation_image_h/c6dc22bb4168989706728943e26eb87e/image-21.jpg)









![class Doubly. Linked. App { public static void main(String[] args) { Doubly. Linked. List class Doubly. Linked. App { public static void main(String[] args) { Doubly. Linked. List](https://slidetodoc.com/presentation_image_h/c6dc22bb4168989706728943e26eb87e/image-31.jpg)
- Slides: 31

Linked List First Link Data next Null

Linked List Operasi: u Penyisipan sebuah item di awal list. u Penghapusan sebuah item di awal list. u Menampilkan isi list

Linked List (insert. First Method) Linked List Link Data First next Null Link Data next

Linked List (delete. First Method) Linked List First Link Data next Null

Linked List (display. List Method) Linked List First Link Data next Null hasil statement hasil statement sekarang = firstsekarang = sekarang. next sekarang =sekarang. next = sekarang. next

class Link { public int i. Data; public double d. Data; public Link next; // ------------------------------public Link(int id, double dd) { i. Data = id; d. Data = dd; } // ------------------------------public void tampilkan. Link() { System. out. print("{" + i. Data + ", " + d. Data + "} "); } }

class Link. List { private Link pertama; // ------------------------------public Link. List() { pertama = null; } // ------------------------------public boolean kosong() { return (pertama==null); } // ------------------------------}

class Link. List (lanjutan) public void sisip. Pertama(int id, double dd) { Link link. Baru = new Link(id, dd); link. Baru. next = pertama; pertama = link. Baru; } // ------------------------------public Link hapus. Pertama() { Link temp = pertama; pertama = pertama. next; return temp; } // -------------------------------

class Link. List (lanjutan) public void tampilkan. List() { System. out. print("List (pertama-->terakhir): "); Link sekarang = pertama; while(sekarang != null) { sekarang. tampilkan. Link(); sekarang = sekarang. next; } System. out. println(""); } // ------------------------------}
![Link List App class Link List App public static void mainString args Link. List. App class Link. List. App { public static void main(String[] args) {](https://slidetodoc.com/presentation_image_h/c6dc22bb4168989706728943e26eb87e/image-10.jpg)
Link. List. App class Link. List. App { public static void main(String[] args) { Link. List list. Q = new Link. List(); list. Q. sisip. Pertama(22, 2. 99); list. Q. sisip. Pertama(44, 4. 99); list. Q. sisip. Pertama(66, 6. 99); list. Q. sisip. Pertama(88, 8. 99); list. Q. tampilkan. List(); while( !list. Q. kosong() ) { Link link. Q = list. Q. hapus. Pertama(); link. Q. tampilkan. Link(); System. out. print(" terhapus"); System. out. println(""); } list. Q. tampilkan. List(); } }

find Method // ------------------------------public Link find(int key) { Link current = first; while(current. i. Data != key) { if(current. next == null) return null; else current = current. next; } return current; } // -------------------------------

delete Method public Link delete(int key) { Link current = first; Link previous = first; while(current. i. Data != key) { if(current. next == null) return null; else { previous = current;

current = current. next; } } if(current == first) first = first. next; else previous. next = current. next; return current; } // ----------------------------

delete Linked List First Link Data next Null previous current

double-Ended List Linked List First Link Data next Null Last

double-ended list Linked List First Null Last Null Link Data next

program class Link { public long d. Data; public Link next; // ---------------------------public Link(long d) { d. Data = d; } // ---------------------------public void display. Link() { System. out. print(“(“+d. Data+”)” + “ ” ); } // ---------------------------}

class First. Last. List { private Link first; private Link last; // ------------------------------public First. Last. List() { first = null; last = null; } // ------------------------------public boolean is. Empty() { return first==null; } // ------------------------------public void insert. First(long dd) { Link new. Link = new Link(dd); if( is. Empty() ) last = new. Link; new. Link. next = first; first = new. Link; } // -------------------------------

// ------------------------------public void insert. Last(long dd) { Link new. Link = new Link(dd); if( is. Empty() ) first = new. Link; else last. next = new. Link; last = new. Link; } // ------------------------------public long delete. First() { long temp = first. d. Data; if(first. next == null) last = null; first = first. next; return temp; } // -------------------------------

public void display. List() { System. out. print(“List (first-->last): “); Link current = first; while(current != null) { current. display. Link(); current = current. next; } System. out. println(“”); } // ------------------------------}
![class First Last App public static void mainString args First Last List class First. Last. App { public static void main(String[] args) { First. Last. List](https://slidetodoc.com/presentation_image_h/c6dc22bb4168989706728943e26eb87e/image-21.jpg)
class First. Last. App { public static void main(String[] args) { First. Last. List the. List = new First. Last. List(); the. List. insert. First(22); the. List. insert. First(44); the. List. insert. First(66); the. List. insert. Last(11); the. List. insert. Last(33); the. List. insert. Last(55); the. List. display. List(); the. List. delete. First(); the. List. display. List(); } // end main() } // end class First. Last. App

Doubly linked-list Linked List First Link Data next Null prev Last Null Link Data next prev

Linked List First Link Data next Null prev Last prev Null Link Data next prev

Program class Link { public long d. Data; public Link next; public Link previous; // ------------------------------public Link(long d) { d. Data = d; } // ------------------------------public void display. Link() { System. out. print(d. Data + “ ”); } // ------------------------------} // end class Link

class Doubly. Linked. List { private Link first; private Link last; // ------------------------------public Doubly. Linked. List() { first = null; last = null; } // ------------------------------public boolean is. Empty() { return first==null; } // -------------------------------

// ------------------------------public void insert. First(long dd) { Link new. Link = new Link(dd); if( is. Empty() ) last = new. Link; else first. previous = new. Link; new. Link. next = first; first = new. Link; } // ------------------------------public void insert. Last(long dd) { Link new. Link = new Link(dd); if( is. Empty() ) first = new. Link; else { last. next = new. Link; new. Link. previous = last; } last = new. Link; } // -------------------------------

// ------------------------------public Link delete. First() { Link temp = first; if(first. next == null) last = null; else first. next. previous = null; first = first. next; return temp; } // ------------------------------public Link delete. Last() { Link temp = last; if(first. next == null) first = null; else last. previous. next = null; last = last. previous; return temp; } // -------------------------------

// ------------------------------// insert dd setelah key public boolean insert. After(long key, long dd) { Link current = first; while(current. d. Data != key) { current = current. next; if(current == null) return false; } Link new. Link = new Link(dd); if(current==last) { new. Link. next = null; last = new. Link; } else { new. Link. next = current. next; // new. Link <-- old next current. next. previous = new. Link; } new. Link. previous = current; current. next = new. Link; return true; } // -------------------------------

// ------------------------------public Link delete. Key(long key) { Link current = first; while(current. d. Data != key) { current = current. next; if(current == null) return null; } if(current==first) first = current. next; else current. previous. next = current. next; if(current==last) last = current. previous; else current. next. previous = current. previous; return current; } // -------------------------------

// ------------------------------public void display. Forward() { System. out. print(“List (first-->last): “); Link current = first; while(current != null) { current. display. Link(); current = current. next; } System. out. println(“”); } // ------------------------------public void display. Backward() { System. out. print(“List (last-->first): “); Link current = last; while(current != null) { current. display. Link(); current = current. previous; } System. out. println(“”); } // ------------------------------} // end class Doubly. Linked. List
![class Doubly Linked App public static void mainString args Doubly Linked List class Doubly. Linked. App { public static void main(String[] args) { Doubly. Linked. List](https://slidetodoc.com/presentation_image_h/c6dc22bb4168989706728943e26eb87e/image-31.jpg)
class Doubly. Linked. App { public static void main(String[] args) { Doubly. Linked. List the. List = new Doubly. Linked. List(); the. List. insert. First(22); the. List. insert. First(44); the. List. insert. First(66); the. List. insert. Last(11); the. List. insert. Last(33); the. List. insert. Last(55); the. List. display. Forward(); the. List. display. Backward(); the. List. delete. First(); the. List. delete. Last(); the. List. delete. Key(11); the. List. display. Forward(); the. List. insert. After(22, 77); the. List. insert. After(33, 88); the. List. display. Forward(); } }
Advantage of linked list
Singly vs doubly linked list
Perbedaan single linked list dan double linked list
Penghapusan node di depan tidak boleh dilakukan jika
First.next = null
X.next = x.next.next
Linked list remove first node
Java data structures
Linked list polynomial addition
Polynomial addition using linked list in python
Site:.com "fill link item" "add link"
Generic linked list java
Jenis linked list
Singly vs doubly linked list
My grown up christmas list link
Market basket analysis
Xor linkedlist
C++ list
Linked list in mips
Definition of linked list
Linked list diagram in java
Advantages and disadvantages of circular linked list
Malloc linked list
Circular single linked list
Concurrent linked list
Single linked list non circular
List adt
Difference between linked list and queue
Circular linked list advantages
Circular linked list definition
Algorithm of single linked list
Priority queue doubly linked list