35-CS106X-Final

# 35-CS106X-Final - CS106X Autumn 2009 Handout 35 CS106X...

This preview shows pages 1–4. Sign up to view the full content.

CS106X Handout 35 Autumn 2009 December 11 th , 2009 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. Encoding General Trees (8) ______ ______ 2. All Possible Expressions (12) ______ ______ 3. Minimum Vertex Covers (12) ______ ______ 4. Muppet Inheritance (8) ______ ______ 5. Short Answer (10) ______ ______ Total (50) ______ ______ SCPD students who want their exams sent back through regular mail, check here: _____

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

View Full Document
2 Problem 1: Encoding General Trees [8 points] A general tree is one where each node has an arbitrary number of children. Here’s an example: It’s possible to encode an arbitrary tree in binary tree form by subscribing to a left-child, right-sibling representation. Each node in the binary tree representation has two children. The left child is the first child of the corresponding node in the general tree, and the right child is the right sibling of the corresponding node in the general tree. So, the above would map to the following binary tree structure: Note, for example, how all of the children of the root in the original tree now form the right spine on the sub-tree that hangs from the root in the new tree. 14 59 37 45 81 22 79 60 73 75 41 90 13 32 11 34 23 12 64 14 22 45 81 59 37 79 60 41 73 75 64 23 12 13 34 90 11 32
3 Write a function called encode , which accepts the root of a general tree and constructs and returns the corresponding binary tree. struct genTreeNode {

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 03/07/2010 for the course CS 201 taught by Professor Selimaksoy during the Spring '09 term at Bilkent University.

### Page1 / 12

35-CS106X-Final - CS106X Autumn 2009 Handout 35 CS106X...

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

View Full Document
Ask a homework question - tutors are online