Overview of Collections Flashcards
What is a collection?
Container for zero or more data objects
Tracks its own size and resizing is automatic
Comes with built-in operations for access, insertions, removals, etc.
What do we do with the details of a collection’s underlying data structures and operations? Why?
We ignore them because they are hidden in the implementation
Built-in python collections
String, Tuple, List, Set, Dictionary
Basic categories of collections
Linear, Hierarchical, Graph, Unordered
Types of linear collections
List, Stack, Queue, Priority Queue
Linear collection characteristics
Elements are ordered by position
Each element except the first has a unique predecessor
Each element except the last has a unique successor
List characteristics
Allow accesses, replacements, insertions, and removals at any position
Stack characteristics
Allow accesses, insertions, and removals at one end only
Queue characteristics
Allow insertions at one end and removals and accesses at the other end
Priority Queue characteristics
Sort elements by priority, but elements with equal priority are added and removed in queue-like order
Types of hierarchical collections
Binary tree, General tree, Binary search tree, Heap
Hierarchical collection characteristics
Each element except the root has a unique predecessor
Each can have zero or more successors
Types of graph collections
Undirected graph, Directed graph
Graph collection characteristics
Each element can have zero or more predecessors
Each can have zero or more successors
Types of unordered collections
Bag, Set, Dictionary