








































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of linked lists, their types, and various operations that can be performed on them in the context of the java collections framework. Topics include insertion, deletion, display, search, and comparison using interfaces such as comparable and comparator. The document also covers the use of arraylist and linkedlist, as well as static utility methods in the collections class for sorting, searching, and finding extremes in collections.
Typology: Lecture notes
1 / 48
This page cannot be seen from the preview
Don't miss anything!









































Mr. James Ombogo
To explore different types of linklists and operations that can be performed on them. To explore the relationship between interfaces and classes in the Java Collections Framework hierarchy. To use the common methods defined in the Collection interface for operating collections. To use the Iterator interface to traverse the elements in a collection To use a for-each loop to traverse the elements in a collection To explore how and when to use ArrayList or LinkedList to store a list of elements. To compare elements using the Comparable interface and the Comparator interface. To use the static utility methods in the Collections class for sorting, searching, shuffling lists, and finding the largest and smallest element in collections (§22.6).
Linked list can be visualized as a chain of nodes, where every node points to the next node. As per above shown illustration, following are the important points to be considered. LinkedList contains an link element called first.
Each Link carries a data fields and a Link Field called next. Each Link is linked with its next link using its next link. Last Link carries a Link as null to mark the end of the list.
Following are the various types of linked list.
Simple Linked List − Item Navigation is forward only.
Doubly Linked List − Items can be navigated forward and backward way.
Circular Linked List − Last item contains link of the first element as next and and first element has link to last element as prev.
Adding a new node in linked list is a more than one step activity. We Shall learn this with diagrams
here. First, create a node using the same structure and find the location where it has to be inserted
Imagine that we are inserting a node B
NewNode.next −> RightNode;
Similar steps should be taken if the node being inserted at the beginning of the list. While putting it at the end, then the second last node of list should point to new node and the new node will point to NULL.
Deletion is also a more than one step process. We shall learn with pictorial representation. First,
locate the target node to be removed, by using searching algorithms.
This operation is a thorough one. We need to make the last node be pointed by the head node and reverse the whole linked list.
Doubly Linked List is a variation of Linked list in which navigation is possible in both ways either forward and backward easily as compared to Single Linked List. Following are important terms to understand the concepts of doubly Linked List Link − Each Link of a linked list can store a data called an element. Next − Each Link of a linked list contain a link to next link called Next. Prev − Each Link of a linked list contain a link to previous link called Prev. LinkedList − A LinkedList contains the connection link to the first Link called First and to the last link called Last.
Following are the basic operations supported by an list. Insertion − add an element at the beginning of the list. Deletion − delete an element at the beginning of the list. Insert Last − add an element in the end of the list. Delete Last − delete an element from the end of the list. Insert After − add an element after an item of the list. Delete − delete an element from the list using key. Display forward − displaying complete list in forward manner. Display backward − displaying complete list in backward manner.
Circular Linked List is a variation of Linked list in which first element points to last element and last element points to first element. Both Singly Linked List and Doubly Linked List can be made into as circular linked list.