Home » Chapter 5 : Data Structures
Other Data Structures
In addition to the data structures we explored o the preceding pages (Lists and Dictionaries), there are many many more (see the List of Data Structures on WikiPedia for example) available in programming. For now, the list and dictionary will serve our purposes, but as you advance your programming skills you will likely find occasions to learn more data structures.
The following list outlines some of the next data structures I recommend learning to use:
Tuple: The tuple is nearly identical to lists, in that it is an indexed sequence however, unlike the list, tuples are immutable.
Set: A set is a collection of unique and unordered elements. Unlike lists and tuples, sets cannot have duplicate values and their order is not guaranteed.
Nodes: In data structures a node is a basic unit within some structures and is usually dipicted in data structure diagrams by either boxes (linked lists, hash tables, etc.) or circles (trees, graphs, etc.). Nodes generally contain memory addresses (pointers) to other nodes and possibly data elements as well.
Linked Lists: A linked list is a fundamental data structures comprised of a sequence of nodes, each element links to the next element in the data structure which links to the next element, and so on. The links are object references to the memory location of each subsequent element in the list. Linked lists can contain any data type, they can be sorted or unsorted and can contain duplicate or unique values.
Stacks: A stack is a data structure that follows a Last-In First-Out (LIFO) pattern of access, like a stack of books. We stack books one on top of another and when we want a book we take one off of the top. The stack data structure in programming is conceptually the same, it is a structure that we put data elements into, one at a time, and then when we want one of the elements we take the last element that was added first.
Queues: A queue is a data structure that follows a First-In First-Out (FIFO) pattern of access, like the line (queue) of people in the image above. People line (queue) up, say for example at a coffee shop. The first person in line was the first one there and will be the first one to receive service. When that person is done they leave and the next (second) person is served, and so on.
Trees: Trees are an abstraction of hierarchical data structures that represent relationships between data (nodes) which we can use in programming to model those relationships.
Graphs: Graphs are used extensively in modeling real-world problems. For example, the map of a computer network in a business can be modeled using a graph. Modeling of social media connections ("friends") can be accomplished using a graph. Determining the shortest flight paths of aircraft between cities can be modeled using graphs.
Maps: Maps are efficient interface containers that store key/value pairs. The keys in a map are the indexes of the structure and they can be any object type in Java. Keys cannot be duplicated in a map and each key maps to one value.