Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
n k
e
d
Linked List
www.eshikshak.co.in
Limitations of Array
To insert or remove an element at an interior location in an ArrayList requires shifting of data and is an O(n) operation.
www.eshikshak.co.in
Limitations of Array
An array has a limited number of elements
routines inserting a new value have to check that there is room Cant increase or decrease its size during execution
Can partially solve this problem by reallocating the array as needed (how much memory to add?)
adding one element at a time could be costly
Data
Link
Link : It contains the address to its successor (and sometimes its predecessor)
www.eshikshak.co.in
www.eshikshak.co.in
The entire linked list is accessed from an external pointer list that points to first node in the list The link field of the last node in the list contains a special value, known as NULL The NULL pointer is used to signal the end of a list
www.eshikshak.co.in
The list with no nodes on it is called the empty list or the null list A list can be initialized to the empty list by list = NULL
www.eshikshak.co.in
www.eshikshak.co.in
The basic operations of Linked List Traverse Insert At Beginning At End At given position Delete At Beginning At End At given position Update At Beginning At End At given position www.eshikshak.co.in
In Memory
ListStart 0 100
ListStart->next = NULL;
ListStart 5 ListStart 108 5 100 ListStart 5 ? ? 108 0