Linked Lists
Michael McMillan
Abstract
Michael McMillan
Abstract
For many applications, data are best stored as lists, and lists occur naturally in day-to-day life—to-do lists, grocery lists, and top-ten lists. In this chapter we explore one particular type of list, the linked list. Although the.NET Framework class library contains several list-based collection classes, the linked list is not among them. The chapter starts with an explanation of why we need linked lists, then we explore two different implementations of the data structure—object-based linked lists and array-based linked lists. The chapter finishes up with several examples of how linked lists can be used for solving computer programming problems you may run across. SHORTCOMINGS OF ARRAYS The array is the natural data structure to use when working with lists. Arrays provide fast access to stored items and are easy to loop through. And, of course, the array is already part of the language and you don't have to use extra memory and processing time using a user-defined data structure. However, as we've seen, the array is not the perfect data structure. Searching for an item in an unordered array can be slow because you might have to visit every element in the array before finding the element you're searching for. Ordered (sorted) arrays are much more efficient for searching, but insertions and deletions take extra time because you have to shift the elements up or down to either make space for an insertion or remove space with a deletion.
A significance statement is not available in the OpenAlex record.
A contribution statement is not available in the OpenAlex record.
Method details are not available in the OpenAlex metadata.
Findings are not separately available in the OpenAlex metadata.
Limitations are not available in the OpenAlex metadata.
Application details are not available in the OpenAlex metadata.
For many applications, data are best stored as lists, and lists occur naturally in day-to-day life—to-do lists, grocery lists, and top-ten lists. In this chapter we explore one particular type of list, the linked list. Although the.NET Framework class library contains several list-based collection classes, the linked list is not among them. The chapter starts with an explanation of why we need linked lists, then we explore two different implementations of the data structure—object-based linked lists and array-based linked lists. The chapter finishes up with several examples of how linked lists can be used for solving computer programming problems you may run across. SHORTCOMINGS OF ARRAYS The array is the natural data structure to use when working with lists. Arrays provide fast access to stored items and are easy to loop through. And, of course, the array is already part of the language and you don't have to use extra memory and processing time using a user-defined data structure. However, as we've seen, the array is not the perfect data structure. Searching for an item in an unordered array can be slow because you might have to visit every element in the array before finding the element you're searching for. Ordered (sorted) arrays are much more efficient for searching, but insertions and deletions take extra time because you have to shift the elements up or down to either make space for an insertion or remove space with a deletion.
Key concepts: Computer science, Linked list, Implementation, Class (philosophy), Data structure, Programming language, Information retrieval, World Wide Web