42-CS107-Practice-Final

42-CS107-Practice-Final - CS107 Spring 2007 Handout 42 June...

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

View Full Document Right Arrow Icon
CS107 Handout 42 Spring 2007 June 1, 2007 CS107 Final Exam Practice Problems Exam Facts First Offering: Friday, June 8 th at 8:30 a.m. in Cubberly Auditorium. Second Offering: Friday, June 8 th at 7:00 p.m. in Cubberly Auditorium. Three hours, open notes, open book, closed computer. You may take the exam at whichever is the more convenient of these two times. I’ll provide documentation for any relevant C, C++, Scheme, and Java built-ins, so don’t go memorizing anything. The final exam I’m presenting here contains many more problems than you’ll see on your final exam. I thought it would be better to give you plenty of practice problems—all drawn from previous midterms and finals—that’ll help you identify the material I consider important. I repeat: This is much longer than anything you’ll see on Friday June 8 th . SCP D students are encouraged to come to campus if at all possible. Those taking it remotely can take it on Friday evening at 7:00 p.m. (when it’ll be posted as a handout) or on Saturday morning. I’ll have my cell phone one me (number listed on exam) and you’ll fax the exam in (fax number also on the exam). Just make sure I have your exam by noon on Saturday, because we’ll need to grade it by then. Material The final is comprehensive but will emphasize topics covered after the midterm. Want to see where you've been? Here's the pretty impressive list of things you've learned in 107: 1. Implementation—stack-heap diagrams, memory layout, structures, arrays and pointers, function calls, parameter passing, local variables, code generation. 2. C— arrays, pointers, malloc , , * , void* , typecasts, function pointers, preprocessor, compiler, linker. 3. Simple Concurrency—threads, semaphores, binary lock, rendezvous, shared global data, race conditions. 4. Scheme—lists, car , cdr , cons , append , map , lambda , apply , let . 5. Java—inheritance, constructors, static methods, overriding, super , code factoring, protected ,
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Problem 1: Matchmaking You keep the names of all your male friends in one C vector (where else?) and the name of all your female friends in a second C vector . Your task is to generate a brand new vector and populate it will the full cross product of men and women as char * , char * pairs. Write a function generateAllCouples that creates a vector , inserts deep copies of all boy-girl pairs, and then returns it. Note that this problem has no C++ component whatsoever. It’s all C.) /** * The primary assumption is that both boys and girls * are C vectors of dynamically allocated C strings, each * initialized as follows. * * vector boys, girls; * VectorNew(&boys, sizeof(char *), StringFree, 0); * VectorNew(&girls, sizeof(char *), StringFree, 0); * * generateAllCouples creates a new C vector of couples * and inserts one such record on behalf of every possible * mapping of boy to girl. The couples own their own strings, * so that none of the three vectors share any memory whatsoever. * Assume that CoupleFree is the VectorFreeFunction that disposes
Background image of page 2
Image of page 3
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 / 11

42-CS107-Practice-Final - CS107 Spring 2007 Handout 42 June...

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

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