section: pset5

14
Section: Pset5 Jordan Jozwiak CS50

Upload: alessandra-tandy

Post on 30-Dec-2015

29 views

Category:

Documents


2 download

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Section: Pset5

Section: Pset5Jordan Jozwiak

CS50

Page 2: Section: Pset5

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

Page 3: Section: Pset5

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

Page 4: Section: Pset5

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?

Page 5: Section: Pset5

Does your TF try too hard?Forensics 2011 Forensics 2012

Page 6: Section: Pset5

Stacks

Last in, first out data structure.

Can ‘pop’ or ‘push’ things to the top of the stack.

Top

Page 7: Section: Pset5

Queues

First in, first out data structure.

“Insert” and “Remove” operations.

Head Tail

Page 8: Section: Pset5

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

Page 9: Section: Pset5

Linked ListsUnlike an array, linked lists allow us to insert

or remove elements in constant time!

42

35

50 NULL

Page 10: Section: Pset5

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.

Page 11: Section: Pset5

Hash TablesGood Hash Functions are:DeterministicUniformly distributed

intxkcd_hash(char *word){ return 4;}

THIS IS

BAD

Page 12: Section: Pset5

Hash Tables: with Linked Lists

Page 13: Section: Pset5

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

Page 14: Section: Pset5

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/