Minggu, 01 Maret 2020

Linked list

Meaning

Linked list is a linear collection of data elements, whose order is not given by their physical placement in memory.

It is a data structure consisting of a collection of nodes which together represent a sequence. In its most basic form, each node contains: data, and a reference (in other words, a link) to the next node in the sequence.

This structure allows for efficient insertion or removal of elements from any position in the sequence during iteration.

And create a faster access, such as random access, is not feasible. Arrays have better cache locality compared to linked lists.

Basic Consept

Singly Linked List

Singly linked lists contain nodes which have a data field as well as 'next' field, which points to the next node in line of nodes. Operations that can be performed on singly linked lists include insertion, deletion and traversal. Singly liked list only have one direction which is leads to NULL.

Doubly Linked List

"Double linked list non circular" adalah Double Linked List yang memiliki 2 buah pointer yaitu pointer next dan prev.

- Pointer next menunjuk pada node setelahnya.

- Pointer prev menunjuk pada node sebelumnya.
Double : artinya field pointer-nya dua buah dan dua arah, ke node sebelum dan sesudahnya.

Linked List : artinya node-node tersebut saling terhubung satu sama lain.

Non Circular : artinya pointer prev dan next-nya akan menunjuk pada NULL.

circular doubly linked list


Circular doubly linked list hampir sama dengan doubly linked list tetapi di node circular doubly linked list memiliki 2 pointer sehingga disini bisa melakukan  perputaran karena node terakhir akan membawa lagi ke head tetapi disini kita bisa berputar menggunakan next dan previous sehingga ada 2 jenis perputaran yaitu head 

Tidak ada komentar:

Posting Komentar