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
Contracts and Clients
Lists, mutability, representations
Contract of service provider and client
15-211
Fundamental Data Structures and
Algorithms
Interface specification
Functionality and correctnes
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 offs
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
To
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
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
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 solv
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
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 searc
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
Algor
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
Brin
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!
htt
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
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 Co
Queues
public interface Queue cfw_
15-211
Fundamental Structures
of Computer Science
public boolean isEmpty () ;
public void
enqueue(Object x)
throws QueueOverflow ;
public Object
Priority Queues
Sept
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
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:
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 th
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. Amort
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
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 th
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 f
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 cod
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 ba
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
Algor
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
Alg
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 st
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
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
algorit