This preview shows pages 1–6. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 University of California, Berkeley College of Engineering Computer Science Division EECS Spring 2003 John Kubiatowicz Prerequisite Quiz February 3, 2003 CS152 Computer Architecture and Engineering This prerequisite quiz will be used in determining class admissions. The use of notes is not allowed during this quiz. Good Luck! Your Name: SID Number: Discussion Section: 1 2 3 4 Total 2 [ This page left for ] 3.141592653589793238462643383279502884197169399375105820974944 3 1) Assume that we have a 16 bit system that uses signed, twoscomplement integers. Perform the following conversions:13 10 to base 2: 13 10 =1101 2 so 13 10 = (1111 1111 1111 0011) 2 FF4E 16 to base 10: FF4E 16 =(1111 1111 0100 1110) 2 = (0000 0000 1011 0010) 2 =(11x16+2)=178 10 52 10 to base 16: 52 10 =34 16 (1111111110111100) 2 to base 10: (1111 1111 1011 1100) 2 =(0000 0000 0100 0100) 2 =(4*16+4)=68 10 8CB3 16 to base 8: 8CB3 16 =(1000 1100 1011 0011) 2 =(1 000 110 010 110 011) 2 =(106263) 8 4 [ This page left for scratch ] 5 2) Below is a recursive routine to add up values for every node in a tree. typedef struct { int value; ; 4 bytes (1 word) node *left; ; 4 byte pointer (1 word) node *right; ; 4 byte pointer (1 word) } node; int sum (node *root) { if (root == (node *)0) { /* Null pointer => empty tree */ return 0; } else { return (node>value) + sum(node>left) + sum(node>right); } } Each item in the tree is a structure with a value, a left pointer, and a right pointer. The sumtree() routine calls itself recursively on the left and right subtrees, adds in the value of the current node, then returns the result. the current node, then returns the result....
View
Full
Document
This homework help was uploaded on 01/29/2008 for the course CS 152 taught by Professor Kubiatowicz during the Spring '04 term at University of California, Berkeley.
 Spring '04
 Kubiatowicz
 Computer Architecture

Click to edit the document details