https://gettingreal.37signals.com/ch02_Whats_Your_Problem.php
Data Structures: An Overview¶
Motivation¶
History¶
Babbage designed the Difference Machine: https://www.youtube.com/watch?v=be1EM3gQkAY to build error-free mathmatical tables. He automated the process of creating printing plates, thereby reducing the typesetting errors of the time.
He then generalized the Difference Machine to the first (if it had been built) Turing-complete computer. It has an arithmetic logic, memory, and control flow (branching & loops).
Ada Lovelace wrote the first algorithm to compute the Bernoulli (Kowa) sequence for the Babbage Analytical Engine.
“As soon as an Analytical Engine exists, it will necessarily guide the future course of the science. Whenever any result is sought by its aid, the question will then arise—By what course of calculation can these results be arrived at by the machine in the shortest time?”
Charles Babbage Passages from the Life of a Philosopher
Babbage’s design was revolutionary in that the computer could store and then retrieve data. Then it was “pegs in a barrel” –like a music box. Today it it’s groups of bits (GOBs).
Storing and Fetching¶
- The Analytical Engine only used fixed point arithmetic (column width of 50).
- Data Structures improve the storing and/or fetching of GOBS.
- Data Structures organize GOBs
Collections¶
GOBs are organized into data structures.
These are then grouped into data types:
- Primitive
- Composite
- Abstract Data Types (ADT)
Primitive¶
Composite¶
Abstract Data Types¶
- Collection (Container)
- List
- Stack
- Queue
- Deque (Double-ended queue)
- Priority queue
- Associative array
- Multimap
- Multiset
- Set
- Tree
- Graph
For this class:
We will consume primitive and composite data types.
- These are encapsulated quite nicely by Python.
- We care about what they do
We will implement ADT
- We care about performance
- We look at their attributes and operations.
Definition¶
Abstract Data Type:
A set of data values and associated operations that are precisely specified independent of any particular implementation.
Note: Since the data values and operations are defined with mathematical precision, rather than as an implementation in a computer language, we may reason about effects of the operations, relations to other abstract data types, whether a program implements the data type, etc.
Paul E. Black, “abstract data type”, in Dictionary of Algorithms and Data Structures [online], Vreda Pieterse and Paul E. Black, eds. 10 February 2005. (accessed TODAY) Available from: http://www.nist.gov/dads/HTML/abstractDataType.html
Attributes¶
- index, key
- node
- edge
- length, size
- value, cargo, information
- next
- previous
- leaf
- head
- tail
Operations¶
In [1]: