12-Section-Handout

12-Section-Handout - CS107 Autu mn 2006 Handou t 12 Section...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS107 Handout 12 Autumn 2006 April 13, 2007 Section Handout Problem 1: Meet The Flintstones Consider the following C-style struct definitions: typedef struct rubble { // need tag name for self-reference int betty; char barney[4]; struct rubble *bammbamm; } rubble; typedef struct { short *wilma[2]; short fred[2]; rubble dino; } flintstone; Accurately diagram what computer memory looks like after the following seven lines of code have executed: rubble *simpsons; flintstone jetsons[4]; simpsons = &jetsons[0].dino; jetsons[1].wilma[3] = (short *) &simpsons; strcpy(simpsons[2].barney, "Bugs Bunny"); ((flintstone *)(jetsons->fred))->dino.bammbamm = simpsons; *(char **)jetson[4].fred = simpsons->barney + 4; Problem 2: Scheme Scheme is a language whose primary built-in data structure is the linked list. Unlike any of the lists you’ve dealt with in C, Scheme lists are fully heterogeneous—that is, the entries needn’t all be the same type. Some example lists are:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/14/2010 for the course CS 107 taught by Professor Cain,g during the Spring '08 term at Stanford.

Page1 / 3

12-Section-Handout - CS107 Autu mn 2006 Handou t 12 Section...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online