15-211 Quiz 2
Page 1 of 3
15-211 : Fundamental Data Structures and Algorithms
Name:
Andrew ID:
Answer the questions in the space provided following each question. We
must be able to clearly understand your answer otherwise it is incorrect. Be
sure to read
Contracts and Clients
Lists, mutability, representations
Contract of service provider and client
15-211
Fundamental Data Structures and
Algorithms
Interface specification
Functionality and correctness expectations
Performance expectations
Hiding of respe
9/30/2010
The Fibonacci Sequence
Dynamic Programming 1
How many rabbits can be produced
from a single pair in a years time?
Assume:
15-211
Fundamental Structures
of Computer Science
New pair of offspring each month
Each pair becomes fertile after one m
11/9/2010
Announcements
Game Trees
PLEASE re-read cheating policy!
www.cs.cmu.edu/~211/policy/cheating.html
15-211
Fundamental Data Structures and
Algorithms
Christopher Langmead
November 9, 2010
Today
Example: 8 Queens
Game Trees
Given: An 8x8 chess
Revision from last time:
Graph Algorithms, Part 2
Testing Bipartiteness
A graph (directed or
undirected) is bipartite
(aka bigraph) if the
vertices can be
divided into two
disjoint sets T V and
U V such that every
edge connects a node
in T to one in U
1
Today
Dynamic Programming 2
Examples of Dynamic Programming
Complete Egg dropping problem
15-211
Fundamental Data Structures and
Algorithms
Longest Common Subsequence
p
Matrix Multiplication
Chris Langmead
October 5, 2010
Review: Dynamic Programming
Models of computation
Understanding computation
15-211
Fundamental Data Structures and
Algorithms
1.
Which problems can be solved by computers?
2.
Which problems cannot?
3.
Which problems can be solved quickly?
4.
Are there fundamental differences among
Tables, Records, Indexes
Table
1
4
A set of records
3
4
Jonathan
Aaron
Joo
Chris
Bill
Ankur
Ian
Ryan
Andrew
Danny
Chris
Peter
Record
15-211
2
5
F
A tuple of fields
Field
5
U
U
U
F
F
U
U
G
U
6
A column of the table
Hashing
9/9/10
An Index structure
Binary trees, inductively
A binary tree is either
nil
Empty, or
15-211
Fundamental Data Structures and
Algorithms
A triple (x,L,R) where
x
x is an object, and
L and R are binary trees
Balanced search trees
Brief note on stacks and queues
Red-Black trees
Reasoning about programs
Thinking about Correctness
One of the central goals of CS is to
develop rigorous and systematic ways of
reasoning about programs.
15-211
Fundamental
Data Structures
and
Algorithms
Rigorous: Based on strict and precise (often
mat
Announcements 1
Binary Search Trees (Part 1)
1st Midterm is next Thursday
Sept 23, 2010
15-211
Fundamental Data Structures and
Algorithms
In class
Cumulative
No cell phones, pdas, computers, etc
Bring student ID
Chris Langmead
September 16, 2010
You may
Correction from last time
Sorting
Tutoring for CS 15-211
15-211
Fundamental Data Structures and
Algorithms
Mudge Library, Tuesday and Thursday
evenings 8:30-11 p.m.
Free!
No appointment necessary!
http:/www.cmu.edu/academicdevelopment/peer-tutoring/
Chris
Announcements (1)
The Analysis of Algorithms
HW 0 due this evening by 11:59 PM
HW 1 goes out today
15-211
Fundamental Data Structures and
Algorithms
Be sure you understand how to use
j
junit
Be sure you understand how FrontDesk
grades
Be sure you unders
Today
Graph Algorithms, Part 1
Graphs
Representation
Basic Algorithms
15-211
Fundamental Data Structures and
Algorithms
Depth-first search
Breadth-first search
Topological sorting
Testing Bipartiteness
Chris Langmead
October 12, 2010
Graphs
a
d
a
d
Announcements
Data Compression
Midterm 1 has been graded
Pick up during recitation
15-211
Fundamental Data Structures and
Algorithms
Chris Langmead
September 28, 2010
Today
Data Compression
Data Compression
Motivation
Reduce storage and/or transmissi
15-211 Quiz 3
Page 1 of 4
15-211 : Fundamental Data Structures and Algorithms
Name:
Andrew ID:
Answer the questions in the space provided following each question. We
must be able to clearly understand your answer otherwise it is incorrect. Be
sure to read
15-211 Quiz 4
Summer 2011
Page 1 of 4
15-211 : Fundamental Data Structures and Algorithms
SOLUTIONS
15-211 Quiz 4
Summer 2011
Page 2 of 4
1. Human compression.
(10)
(a) Consider the following string:
she sells sea shells
and show the Human codeword for ea
15-211 Quiz 5
Page 1 of 5
15-211 : Fundamental Data Structures and Algorithms
SOLUTIONS
15-211 Quiz 5
Page 2 of 5
1. Graph theory: Given a simple graph with V vertices and E edges.
(10)
(a) What is the worst-case runtime (in O-notation) of the BFS on a gr
15-211: HW1
Page 1 of ?
15-211 Fundamental Data Structures
Summer 2011
HW 1: Theory Questions
Due: Friday May 20 in class
Name:
Andrew ID:
These questions count for 20% of the homework grade.
1. Amortized Array-Based Dictionary.
Consider a simple amortize
15-211 Quiz 1
Page 1 of 4
15-211 : Fundamental Data Structures and Algorithms
Name:
Andrew ID:
Answer the questions in the space provided following each question. We
must be able to clearly understand your answer otherwise it is incorrect. Be
sure to read
Dynamic Programming Notes
DYNAMIC PROGRAMMING (DP)
Not much to do with dynamic or programming
idea from control theory
Programming really refers to the use of a table
Dynamicrefers to something that changes (eg: table gets updated)
DP Algorithmic Tec
15-211: Assignment 4
Theory Questions
Due: June 10, 2011 in class
These questions count for 20% of the homework grade.
Question
Points Score
1
5
2
9
3
6
Total:
20
1
1. Human code.
(2)
(a) Encode the following string of numbers using Human encoding:
012123
15-211: Assignment 2
Theory Questions
Due: May 27, 2011 in class
These questions count for 30% of the homework grade.
1. (5 points) Converting Recursive Code to DP. Is it possible to speed up this code
using dynamic programming? If so, show how; if not, e
15-211: Assignment 3
Theory Questions
Due: June 03, 2011 in class
These questions count for 20% of the homework grade.
1
211 Trees
The AVL tree invariants do a good job of ensuring that the tree is balanced, but it is also
incredibly strict. So, we introd
Plan for the next several lectures
Union Find
15-211
Fundamental Structures of Computer Science
T
R
T
R
T
R
T
R
24-Aug
26-Aug
31-Aug
2-Sep
7-Sep
9-Sep
14-Sep
16-Sep
Introduction: maze
Union-find
Algorithms and analysis
General Trees
Stacks, queues
Hashing
Today
Welcome and Introduction
Mazes
Abstracting from shrubbery
Geometry, Graphs, Trees, Sets
Kruskals algorithm
Union-find algorithm
Depth-first search
15-211
Fundamental Data Structures and
Algorithms
Chris Langmead and Bill Scherlis
http:/www.cs.c
Announcements
Binary Search Trees (Part 2)
1st Midterm is on Thursday
Sept 23, 2010
15-211
Fundamental Data Structures and
Algorithms
In class
Cumulative
No cell phones, pdas, computers, etc
Bring student ID
Chris Langmead
September 21, 2010
Today
You ma
String Matching
Introduction to
String Matching
Text string
T[0.N-1] =
15-211
Fundamental Data Structures and
Algorithms
Pattern string
P[0.M-1] = growled
Where is the first
instance of P in T?
Oct 28, 2010
String Matching
T[7438.7444]
Applications
T
10/19/2010
Today
Graphs III
Single Source Shortest Paths (SSSP)
Unweighted Graphs: BFS
15-211
Weighted Graphs:
Fundamental Data Structures and
Algorithms
Non-negative weights:
h
Dijkstras
k
algorithm
l
h
Non-negative cycles: SSSP on DAGs
Arbitrary Gr