Java Reference
In-Depth Information
Chapter 3
Linked Lists
In this chapter, we will explain the following:
•
The notion of a linked list
•
How to write declarations for working with a linked list
•
How to count the nodes in a linked list
•
How to search for an item in a linked list
•
How to find the last node in a linked list
•
The difference between static storage and dynamic storage allocation
•
How to build a linked list by adding a new item at the end of the list
•
How to insert a node into a linked list
•
How to build a linked list by adding a new item at the head of the list
•
How to delete items from a linked list
•
How to build a linked list by adding a new item in such a way that the list is always sorted
•
How to organize your Java files
•
How to use linked lists to determine whether a phrase is a palindrome
•
How to save a linked list
•
The differences between using linked lists and arrays for storing a list of items
•
How to represent a linked list using arrays
•
How to merge two sorted linked lists
•
The concept of a circular list and a doubly linked list
3.1 Defining Linked Lists
When values are stored in a one-dimensional array (
x
[0] to
x
[n], say), they can be thought of as being organized as a
“linear list.” Consider each item in the array as a
node
. A linear list means that the nodes are arranged in a linear order
such that the following holds:
Search WWH ::
Custom Search