37-CS106X-Final

37-CS106X-Final - CS106X Autumn 2010 Handout 37 December...

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

View Full Document Right Arrow Icon
CS106X Handout 37 Autumn 2010 December 10 th , 2010 CS106X Final Examination This is an open-note, open-book, open-course-reader exam. You can refer to any course handouts, handwritten lecture notes, or printouts of any code relevant to a CS106X assignment. You may not use any laptops, cell phones, or handheld devices of any sort. You have exactly three hours to complete this exam. Anyone taking the exam remotely can call in to ask questions: 415-205-2242. Remote exam takers should fax their exams to 650-723-6092 and hold on to the original until it’s clear the fax was complete and legible. Good luck! Last Name: _____________________ First Name: _____________________ I accept the letter and spirit of the honor code. I’ve neither given nor received aid on this exam. I pledge to write more neatly than I ever have in my entire life. (signed) __________________________________________________________ Score Grader 1. Generating Numbers (8) ______ ______ 2. Linked Structures (20) ______ ______ 3. Milk & Cookie Inheritance (8) ______ ______ 4. Complete Graphs, Cliques (14) ______ ______ Total (50) ______ ______ SCPD students who want their exams sent back through regular mail, check here: _____
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: Generating Numbers [8 points] Implement a recursive backtracking function called canConstruct which, given a set of cubes with numbers of each of their six sides, one can construct a target number from some subset of the cubes. So, given the following five cubes (shown as cutouts that can fold into cubes): we could form 4117143 from cubes 2, 0, and 4 for their 41, 17, and 143. Or we could form 513777244 from cubes 1, 4, 3, and 1 for their 513, 777, 2, and 44. Basically, can you select cubes in some order, choose a side to be face up, and spell out some target number? canConstruct is supposed to answer that. Assume each cube is modeled as a one-field struct : struct cube { int sides[6]; }; Implement canConstruct in the space below and on the next page: bool canConstruct(Vector<cube>& cubes, int target) { 17 44 86 14 3 142 43 61 513 42 67 7 12 32 41 553 939 433 2 3 56 15 231 352 431 777 62 143 232 35
Background image of page 2
3
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Problem 2: Linked Structures [20 points] a) [5 points] Write a function stretchList that takes a nonempty linked list of integers and
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/13/2011 for the course CS 106X taught by Professor Cain,g during the Fall '08 term at Stanford.

Page1 / 12

37-CS106X-Final - CS106X Autumn 2010 Handout 37 December...

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

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