Class: Computer Science 101
Date: 10/25/23
Topic: Data Structures
What are they? Ways to organize and store data to be used efficiently.
Arrays:
Ordered collection of elements of the same data type.
Stored in contiguous memory locations.
Fast access to elements using an index (O(1)).
Adding/deleting elements can be slow (O(n)).
Linked Lists:
A sequence of nodes, where each node contains data and a pointer to the next node.
Can be single, double, or circular.
Adding/deleting is fast (O(1)), but access can be slow (O(n)).
Stacks:
A Last-In, First-Out (LIFO) data structure.
Operations: push (add to top), pop (remove from top).
Think of a stack of plates.
Queues:
A First-In, First-Out (FIFO) data structure.
Operations: enqueue (add to back), dequeue (remove from front).
Think of a line at a store.