Chapter 2
Sets and Linked Lists
IN THIS CHAPTER
Working with sets
Creating and modifying a linked list
Identifying problems with sets and linked lists
An array can be handy for storing data that consists of the same type of information, such as integers. However, arrays can often be too restrictive. You must define the size of an array ahead of time, and you can only store one data type. In addition, searching, rearranging, or deleting data from an array can be cumbersome.
To solve the problems of arrays, programming languages have come up with a variety of solutions. The obvious solution involves modifying the way arrays work, such as letting you create dynamic (resizable) arrays that can store a special Variant data type. Unlike an Integer data type (which can hold only whole numbers) or a String data type (which can hold only text), a Variant data type can hold both numbers and text. (Not all programming languages offer dynamic arrays or Variant data types.)
Instead of modifying the way arrays work, many programming languages allow you to create other types of data structures. Two popular alternatives to arrays are sets and lists. This chapter shows you how to use sets and lists ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access