CS 223 - Spring 2017. 2/6
Welcome to CS 223!
Logical problem of the day
printf("%d %d\n", n++, n++);
What happens above?
Lecture 7: Introduction to C: hw3 + structs, linked lists, hash tables
The office hours are
Sun/Tue/Thu 8-11 PM at Hillhouse 17 Rm 111.
My office hours this week are Wednesday 4-5pm.
Reminder to speaker: use the microphone in Davies.
Michael Ljung's presentation demonstrated Brook's Law:
The Mythical Man Month.
Accenture Case Study for Healthcare.gov
Per piazza: hw1 grade reports have been emailed
I have sent out the grade reports for hw1.
Here are the statistics:
Max 36 31
Min 0 0
Avg 30.9 9.6
Median 33 9
Stdev 7.8 5.7
The min and average data are not very meaningful. Some hw's did not
compile and some students neglected to include their total time in
their log files -- or did not submit a log file.
If your code did not compile, you should fix it and resubmit, without
If you lost points otherwise, you too may resubmit and get 50%
incremental credit. For example, if you got 30/36 and you resubmit
for 36/36, you will get an additional 3 points (36-30 * 50%).
I will review this in class today as well.
p.s. I will post hw grades to classes v2 once the resubmit process concludes.
The trajectory of the course.
- By the time you finish hw3, you will have learned
almost all the C you need to know.
Midterm exam Wednesday February 22nd in class.
- After the exam, we will focus on the following data structures and
stacks, queues, trees, binary search, graphs, heaps,
and dynamic programming.
- You will continue to use pointers, malloc, valgrind, recursion, strings,
and the other bag of tricks.
It is like you have learned how to use various tools (hammers,
saws, drills, measuring tapes) and materials (lumber, nails, screws,
glue) and now we will build stuff: walls, bookshelves, dining room tables,
Problem set 3
Piazza note about pointers
Private question from piazza:
Why are struct elt and struct hash commented out in hash.h? If I want
them to be available to both hash.c and Callme.c, shouldn't they be
Callme.c should not reference struct elt or struct hash directly.
Those are encapsulated in hash.c.
I defined them as comments in hash.h so you can define them in hash.c
Lecture Starts Here
struct.c Basic date struct,
and recursive person struct, with and without pointers and malloc.
You can use structs to make new data types. Here is a string data type
that includes the length of the string.
Aspnes: Linked Lists
Structs are just fine for creating single data type instances, like strings.
It is usually more interesting to create data structures that actually
produce structures. The simplest structure is a linked list.
We will later see more complex structures, like trees and graphs, which
are variations on linked lists.
Aspnes: Hash Tables
exhash.c integer keys, linear probing
exhash2.c string keys, linear probing
examplehash.c integer keys, linear probing, dummy item for deletes
examplehash2.c string keys, linear probing, dummy item for deletes
hw3/hashtest.c uses hash.h,
string keys, linked lists
hw3/bighashtest.c uses hash.h,
- Determinism - consider a random number generator as a hash function
- Uniformity - Maintain constant load factor