1.1 Algorithm Paradigms
1.1 Algorithm Paradigms
to
Algorithms
CS 251 – Data Structures
and Algorithms
Algorithms and Data Structures Table of Contents
01 Why do we care?
Algorithmic Paradigms
03 Can algorithms follow an
established pattern?
01
Algorithms and Data Structures
Why do we care?
Algorithms
if (n <= 1) if (n <= 1)
{ {
return false; return false;
} }
if (n % i == 0) if (n % i == 0)
{ {
return false; return false;
} }
} }
Read Write
At (key) Add (key [,item])
Find (key) Insert (key [,item])
Get (key) Edit (key [,item])
Search (key) Update (key [,item])
Lookup (key) Delete (key)
Exists (key) Swap (key1, key2)
Could we design Could we design
algorithms data structures
without data without
structures? algorithms?
We analyze A&DSs because:
01 02
Predict Performance Comparison
“How much time/space “Which one is [objectively]
does it require?” better?”
03 04
Provide Guarantees Theoretical Basis
“Will it always work?” “Can we make a theory
out of it?”
02
Examples
Thankfully, someone cared
Discrete Fourier Transform
- Wikipedia
Example 1: Find 6
5 4 8 1 0 6 9 3
Example 2: Find 6 again
0 1 3 4 5 6 8 9
Example 1 Example 2
5 4 8 1 0 6 9 3 0 1 3 4 5 6 8 9