[Home]
CS 223  Spring 2017. 4/19
Welcome to CS 223!
Logical problem of the day
lp0419.c
int main()
{
int n;
printf("Enter a number:\n");
scanf("%d\n",n);
printf("You entered %d \n",n);
return 0;
}
What is going on here?
lp0419b.c
#define PrintInt(expr) printf("%s : %d\n",#expr,(expr))
int FiveTimes(int a)
{
int t;
t = a<<2 + a;
return t;
}
int main()
{
int a = 1, b = 2,c = 3;
PrintInt(FiveTimes(a));
PrintInt(FiveTimes(b));
PrintInt(FiveTimes(c));
return 0;
}
What is going on here? (See Aspnes:
macros for explanation of "#expr"  this is a useful trick!)
Administrivia
Office hours:
The office hours are
Sun/Tue/Thu 811 PM at Hillhouse 17 Rm 111.
My office hours this week are Wednesday 35pm. (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
Women
in Tech talk: Jen Bourney, Google Thursday Noon, 25 Science Park, Room 125.
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 23, 24 trees, which are actually subtypes 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) [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.
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.
Lecture 23: Guest Lecture: Facebook
[Home]