Download - Section: Pset5
Section: Pset5Jordan Jozwiak
CS50
AnnouncementsPset4 will be returned by Tuesday night (but
hopefully tonight!)If you haven’t already, pick up Quiz 0 at end
of class!Don’t forget to add music to our
coding playlist!Link sent out via email last week
This WeekBrief Feedback/Questions for Pset4Section of Questions (and brief discussion
with slides)Stack (~10 min)Queue (~10 min)Singly Linked lists (~50 min)
If time…Hash tables
Pset4 Feedbackbf.bfSize vs. bi.biSizeImage
bf.bfOffBitsuint8_t, uint32_t, int32_t, and uint16_tJunk data in an image – image appears the
same but it has a larger file size? How?
Does your TF try too hard?Forensics 2011 Forensics 2012
Stacks
Last in, first out data structure.
Can ‘pop’ or ‘push’ things to the top of the stack.
Top
Queues
First in, first out data structure.
“Insert” and “Remove” operations.
Head Tail
Linked ListsData structure composed of a set of structs.Each struct contains a piece of data and a
pointer to the next struct.
42 50typedef struct node { int num; struct node *next;} node;
struct node
null
int numstruct node
*next
Linked ListsUnlike an array, linked lists allow us to insert
or remove elements in constant time!
42
35
50 NULL
Hash TablesConsists of an array and a hash function.Hash function maps input to an index in the
associated array.Allows us to check whether something is
contained in a data structure without checking through the entire thing.
Hash TablesGood Hash Functions are:DeterministicUniformly distributed
intxkcd_hash(char *word){ return 4;}
THIS IS
BAD
Hash Tables: with Linked Lists
Coding time!!!stack.c (~10 min)queue.c (~10 min)sll.c (~50 min)
Get the code…cd ~/Dropboxwget http://
cdn.cs50.net/2012/fall/sections/6/section6.zipunzip section6.zip
On your way out…Don’t forget about the BIG BOARD! (give it a
shot)Remember that you can access section
powerpoints and SOQ solutions at http://cloud.cs50.net/~jjozwiak/