Skip to content

Latest commit

 

History

History

algorithms

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Algorithms

Discrete Math and Algorithms are hard.

Remember -- all of these algorithms were discovered (or refined for computers) over the last 70+ years.
No one person sat down and conjured them up in a few sessions like this class will. They are elementary or fundamental, they are not simple or trivial.

If all of these problems are solved, why are we re-solving or re-analyzing them? Because if you don't learn on solved problems, you'll never be able to tackle unsolved ones. Also, the general problem solving process sharpens our process that we'll apply to programming -- think of isolating a single skill, like a tennis serve or basketball free throw.

Teaching Tools

Resources

Functional-oriented

Visualizations

Less academic/technical

More academic/technical

Courses

MIT Courses

in prereq order:

Data Structures

structure and semantics

  • Bag (multiset)- non-unique; add and iterate
  • Set (USet)- unique; add and iterate; unordered
  • SSet (sorted set) - supports successor find
  • Hash table (map, hash map, associative array, dictionary). A symbol table is usually implemented using a hash table, and is sometimes referred to synonymously. Effectively a set of tuples queryable by the 1st element in the tuples.
  • Queue - FIFO
  • Pushdown stack - LIFO
  • Priority Queue - highest priority goes to top. usually implemented using heap.
  • Array
  • Vector
  • List
  • Non-empty List
  • Chain - list-like, with constant time prepending and appending. See Cats Chain
  • Binary tree
  • Heap

Shuffling

Sorts

  • Bubble sort (sinking sort) - repeatedly pass through the list and compare adjacent elements, until the list is sorted
  • Selection - repeatedly find the next lowest value in the remaining list and swap to head. slow, but, data movement is minimal
  • Insertion - repeatedly swap the head of the unsorted partition with the next higher value, then move to the next and repeat. fast for already-sorted data. what most people use for sorting cards.
  • Shell - h-sorted array -- insertion sort with h interleaved sorted sequences, gets items closer to their eventual location with each reduction of h . Ciura's gap sequence [701, 301, 132, 57, 23, 10, 4, 1]
  • Mergesort - divide-and-conquer -- recursively sort and combine sub-lists
  • Quicksort - recursively sort lists into bigger/smaller than pivot (why not called pivot sort) Tony Hoare
  • scan from right and left to find two elements that are both out of order, then swap
  • Introsort - quicksort, then heap sort for small sets
  • Heapsort
  • Timsort