140 likes | 322 Views
CS50. Section: Pset5. Jordan Jozwiak. Announcements. Pset4 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 Week.
E N D
CS50 Section: Pset5 Jordan Jozwiak
Announcements • Pset4 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 Week • Brief Feedback/Questions for Pset4 • Section of Questions (and brief discussion with slides) • Stack (~10 min) • Queue (~10 min) • Singly Linked lists (~50 min) • If time… • Hash tables
Pset4 Feedback • bf.bfSize vs. bi.biSizeImage • bf.bfOffBits • uint8_t, uint32_t, int32_t, and uint16_t • Junk 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 Lists • Data structure composed of a set of structs. • Each struct contains a piece of data and a pointer to the next struct. struct node *next int num typedefstruct node { int num; struct node *next; } node; 42 50 null struct node
Linked Lists • Unlike an array, linked lists allow us to insert or remove elements in constant time! 42 50 NULL 35
Hash Tables • Consists 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 Tables Good Hash Functions are: • Deterministic • Uniformly distributed int xkcd_hash(char *word) { return 4; } THIS IS BAD
Coding time!!! • stack.c(~10 min) • queue.c(~10 min) • sll.c(~50 min) • Get the code… • cd ~/Dropbox • wgethttp://cdn.cs50.net/2012/fall/sections/6/section6.zip • unzip 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/