Maggie Johnson
CS103B
Handout #9a
List Applications:
Simulations
Longest Common Subsequence
Key topics:
* Queues and Simulation
* Introduction & Definitions
* Recursive Definition of the Length of an LCS
* Dynamic Programming Algorithm for LCS
* Finding a
List Applications:
Simulations
Longest Common Subsequence
CS 103B
Stanford University
Spring 2008
April 25th, 2008
Outline
Table of Contents
Outline
1
List Refresher
Refresher
Special Lists
2
Longest Common Subsequence
Overview
Algorithm
CS 103B (Stanford
Maggie Johnson
Handout #11
CS103B
Trees I
Key topics:
* Hierarchical Structures
* Tree Terminology
* Trees and Recursion
* Heaps
Hierarchical Structures
Trees are a very useful conceptual tool for representing relationships among certain classes of items.
Introduction to Trees
CS 103B
Stanford University
April 28, 2008
Trees I
1
Outline
Hierarchical Structures
Tree Terminology
Trees and Recursion
Heaps
Trees I
2
Hierarchical Structures
Conceptual tool for
representing relationships
among certain classes of
Maggie Johnson
Handout #12
CS103B
Structural Induction & Proofs on Trees
Key Topics
* Structural Induction
* Other Methods of Proof for Trees
* Node Induction
_
In 103A, we saw a number of inductive proofs concerning integers and sequences. We would
assum
Maggie Johnson
Handout #13
CS103B
Trees: Applications
Key Topics
* A Computer's Language
* Generating Assembly Code from Binary Trees
* File System Design
* FATs and Inodes
* Decision Trees
_
A Computer's Language
At the lowest level, the only language th
Maggie Johnson
Handout #14
CS103B
Graph Theory: The Basics
Key Topics
* Introduction
* Graph Lingo
* Some Special Graphs
* Applications of Special Graphs
* Graph Isomorphism
* Graph Traversals
* Stable Marriage Problem
_
A graph is a convenient representa
Maggie Johnson
CS103B
Handout #16
Paths and Circuits
Key Topics
* The Bridges of Knigsberg
* Some Definitions
* Euler Circuits
* Hamilton Circuits
* The Traveling Salesperson problem
_
In the introductory graph handout, we talked about how the subject of
Maggie Johnson
CS103B
Handout #17
Shortest Path Algorithms
Key Topics
* Introduction
* Dijkstra's Algorithm
* Floyd's Algorithm
* And One More.
As shown last time in the Traveling Salesperson Problem, many problems can be modeled using
graphs with weights
Maggie Johnson
CS103B
Handout #19
Minimal Spanning Trees
Key Topics:
* Planar Graphs
* Spanning Trees: Algorithms and Applications
_
Planar Graphs
Say you have three houses, each of which must be hooked up to three utilities:
One way to represent this is
Maggie Johnson
CS103B
Handout #20
Graph Coloring
Key Topics:
* Introduction
* Coloring Algorithms
* Multicolorings
* Coloring of Planar Graphs
_
Introduction
What is the smallest number of colors (patterns) necessary to paint the map above so that
no two
Maggie Johnson
CS103B
Handout #21
Graph Applications
Key Topics:
* Deadlock Detection
* Cliques
* Orientation & Connected Components
* The Chinese Postman Problem
* Instant Insanity
Deadlock Detection
Deadlock: Waiting for an event that will never happen.
Maggie Johnson
CS103B
Handout #22
Languages & Regular Expressions
Key Topics
* Theory of Formal Languages
* Some Definitions
* Regular Expressions
* Inductions in Formal Languages
* Other Proofs for Regular Expressions
_
Theory of Formal Languages
In the
Maggie Johnson
CS103B
Handout #24
Finite Automata
Key Topics
Some Regular Expression Practice
Introduction
Finite Automata
Non-deterministic Finite Automata
_
Some Regular Expression Practice
Define a regular expression for cfw_ , aa, ba, aaaa, aaba, baba
Maggie Johnson
Handout #25
CS103B
Context-Free Grammars
Key Topics
* Introduction
* Context Free Grammars
* Parse Trees
_
Thanks to Mehran Sahami for portions of this handout
Introduction
As you may know, the earliest programs were written in either machi
Maggie Johnson
CS103B
Handout #8
Infinite Sets and Countability
Key topics:
* Infinite Sets
* Diagonalization
* Russell's Paradox
* The Beginnings of Theoretical Computer Science
Infinite Sets
In a finite set, we can always designate one element as the fi
Maggie Johnson
Handout #6
CS103B
Sets
Key topics:
Introduction and Definitions
Set Operations
Set Identities
Cartesian Product
Proofs about Sets
Set Applications
The first major abstraction that we will consider is a set. Sets are the most basic of mathem
P(n): Every planar graph is 5-colorable.
Base case
Inductive hypothesis
Proof:
Let G be a planar graph with n+1 vertices. We know that G
contains a vertex v whose degree is at most 5. The graph G
v is a planar graph with n vertices and is covered by the
Mehran Sahami CS103B
Handout #3 January 7, 2009
Functions, Functions. Everywhere!
Thanks to Maggie Johnson for some portions of this handout.
In CS103A, it is likely that you already received an introduction to functions. Since we'll be working more with
Mehran Sahami CS103B
Handout #4 January 7, 2009
Introduction to Sets
Portions of this handout was originally written by Maggie Johnson, however she cannot be held responsible for the humorless jokes now contained herein.
Remembering those halcyon days of
Mehran Sahami CS103B
Handout #5 January 9, 2009
Infinite Sets and Countability
Thanks to Maggie Johnson for some portions of this handout.
Infinite Sets
In a finite set, we can always designate one element as the first member, another as the second member
Mehran Sahami CS103B
Handout #10 January 23, 2009
Analysis of Algorithms: The Recursive Case
We again thank Maggie Johnson for portions of this handout.
Up until now, we have been analyzing non-recursive algorithms, looking at how big-Oh notation may be u
Mehran Sahami CS103B
Handout #11 January 23, 2009
Analyzing Searching and Sorting
In examining methods to analyze both recursive and non-recursive algorithms, it is only fitting to spend a little time looking at a variety of common algorithms and their co
Mehran Sahami CS103B
Handout #12 January 23, 2009
Problem Set #2 Due: 11:00am on Monday, February 2nd
1. Let R be a relation on the set cfw_1, 2, 3, 4, 5 containing the ordered pairs: cfw_<1,1>,<1,2>,<1,3>,<2,3>,<2,4>,<3,1>,<3,4>,<3,5>,<4,2>,<4,5>,<5,1>,<
Mehran Sahami CS103B
Handout #13 January 28, 2009
Managing a Bestiary of Algorithms: Complexity Classes and NP-Completeness
Thanks to Maggie Johnson for some portions of this handout.
A Quick Introduction to NP-Completeness
Imagine that you have decided t
Mehran Sahami CS103B
Handout #16 February 2, 2009
Problem Set #3 Due: 11:00am on Wednesday, February 11th
Note: in the problems below in which you are asked for a big-Oh running time, we are looking for a tight big-Oh bound (analogous to the big-Theta ()
Mehran Sahami CS103B
Handout #17 February 2, 2009
Introduction to Trees
Hierarchical Structures
Trees are very useful conceptual tools for representing relationships among certain classes of items. For example, trees can be used to represent familial rela
Mehran Sahami CS103B
Handout #19 February 6, 2009
Practice Midterm Problems
Note: the number of problems here is a larger than you will see on the actual midterm. More problems are provided here just to give you a bit more practice on a broader set of the