[Home]
CS 223 - Spring 2017. 4/12
Welcome to CS 223!
Logical problem of the day
lp0412.c
#include
int main()
{
int j=43;
printf("%d\n",printf("%d",printf("%d",j)));
return 0;
}
What is going on here?
Lecture 21: Dynamic Programming
Administrivia
Office hours:
The office hours are
Sun/Tue/Thu 8-11 PM at Hillhouse 17 Rm 111.
My office hours this week are Wednesday 3-5pm.
The ta's have posted a poll on piazza to solicit topics for review sessions.
Check it and fill it. -- They are now offering mini review sessions.
See piazza note
Assignment 6
Problem set 6
See piazza note Note: this means that you do not call destroyHeap in Fire.c. (Why?)
Assignment 7
Problem set 7
video of
another solution DO NOT IMPLEMENT THIS.
We have also released a program /c/cs223/hw7/Wordsdemo which prints
out copious intermediate results when given the debug flag.
Final Exam
In class on Monday April 24th.
Topics for final exam
and
Sample questions for final exam (from last year) (No 2-3, 2-4 trees, which are actually sub-types of B trees.)
Lecture Starts Here
Red Black Trees
Aspnes: red black trees
Red Black tree != AVL tree:
Red black trees.
Introduction
Animation
C++ Implementation
rb.cpp
C++
- Mostly a superset of C. It is difficult, but not impossible,
to write legal C code that is not legal C++.
- Object oriented: classes, constructors (new, not
malloc), destructors,
encapsulation (private, protected, public),
inheritance, polymorphism, operator overloading.
- I/O streams
- Templates
- Exception handling
- Standard Library - better designed than C's.
B Trees
Data Structure Visualizations
Aspnes: B trees
https://en.wikipedia.org/wiki/B-tree
https://en.wikipedia.org/wiki/B+ tree
Dynamic Programming
Aspnes: Dynamic Programming
fib.c after Aspnes. Uses
array instead of hash table. Issue with fib2(45).
See revised code in fib2.c
fib.py Python version with
memoization.
Minimum coin changing problem Note: greedy algorithm is not always optimal.
Recursive solution: mcc.c
with command line args: mccargs.c
Dynamic programming solution: mccdp.c
with command line args: mccdpargs.c
(Knapsack problem, related to bin packing from hw2.)
lis.c
lis_test.c longest increasing
subsequence, from Aspnes.
[Home]