CS 223 - Spring 2017. 4/19
Welcome to CS 223!
Logical problem of the day
printf("Enter a number:\n");
printf("You entered %d \n",n);
What is going on here?
#define PrintInt(expr) printf("%s : %d\n",#expr,(expr))
int FiveTimes(int a)
t = a<<2 + a;
int a = 1, b = 2,c = 3;
What is going on here? (See Aspnes:
macros for explanation of "#expr" - this is a useful trick!)
The office hours are
Sun/Tue/Thu 8-11 PM at Hillhouse 17 Rm 111.
My office hours this week are Wednesday 3-5pm. (today)
Question about ETA for hw grades: hw4 grades have been posted.
resubmission deadline Monday May 1st at midnight.
Float review session: Friday 3 - 5pm, Digital Humanities Lab
in Tech talk: Jen Bourney, Google Thursday Noon, 25 Science Park, Room 125.
Problem set 7
Revised hw7 (new pseudo code)
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.
In class on Monday April 24th.
Topics for final exam
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?
- Stacks and Queues
create queue with two stacks (question from previous exam)
queuetest.c (uses Stack)
- Heaps and priority queues
Van Wyk: Priority Queues
- Binary search
Van Wyk: Searching
- 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):
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) [Note: k in sorts refers variously to
number of buckets (bucket sort), number of digits (radix sort), and the difference
in the minimum and maximum key values (counting sort). You can click on the algorithm for more information.]
- Review all code in code directory,
including logical problems.
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
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_test.c longest increasing
subsequence, from Aspnes.
Lecture 23: Guest Lecture: Facebook