[Home]
CS 223 - Spring 2017. 4/17
Welcome to CS 223!
Logical problem of the day
lp0417.c
int main()
{
int a=1;
switch(a)
{ int b=20;
case 1: printf("b is %d\n",b);
break;
default:printf("b is %d\n",b);
break;
}
return 0;
}
What is going on here?
lp0417b.c (bonus lp! It is worth it!)
int main()
{
int i;
i = 10;
printf("i : %d\n",i);
printf("sizeof(i++) is: %lu\n",sizeof(i++));
printf("i : %d\n",i);
return 0;
}
What is going on here?
Lecture 22: Dynamic Programming and Exam Review
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.
We will have guest speakers from Facebook on Wednesday.
Assignment 7
Problem set 7
Revised hw7 (new pseudo code)
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.)
Change in specification: (a) given the following code, what is the output and why?
Review topics
- Stacks and Queues
create queue with two stacks (question from previous exam)
queuetest.c (uses Stack)
stacklist.c
- Heaps and priority queues
Van Wyk: Priority Queues
heap.c
- Binary search
Van Wyk: Searching
btreeintargs.c
- Trees (implementation and behavior)
binary search tree
heap Insert into empty tree: 2, 5, 1, 7, 4, 10. Draw tree. Delete 1. Draw tree.
- Trees (behavior):
AVL,
Red Black,
B Trees, Insert into empty tree: 2, 5, 1, 7, 4, 10. Draw tree. Delete 1. Draw tree.
Van Wyk: Sorted Lists (balanced trees)
- Graphs: best first search, depth first search, best
first search, connected, directed (focus on hw6)
Van Wyk: Graphs
- Dynamic Programming and memoization (see below)
-
Runtime complexity for standard operations on various
data structures and related algorithms, e.g., access, search,
insertion, deletion (average, worst)
- Review all code in code directory,
including logical problems.
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]