fa08-sl-ef - ECE 3035 5 problems 9 pages Computing Mechanisms Final Exam Fall 2008 12 December 2008 Instructions This is a closed book closed note exam

# fa08-sl-ef - ECE 3035 5 problems 9 pages Computing...

This preview shows page 1 - 5 out of 9 pages.

ECE 3035 Computing Mechanisms Fall 2008 5 problems, 9 pages Final Exam 12 December 2008 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate the pages of the exam. For maximum credit, show your work. Good Luck! Your Name ( please print ) ________________________________________________ 1 2 3 4 5 Total 26 28 30 20 36 140 1
ECE 3035 Computing Mechanisms Fall 2008 5 problems, 9 pages Final Exam 12 December 2008 Problem 1 (2 parts, 26 points) Compiling Part A (14 points) Draw the control flow graph corresponding to the following C code fragment. Be sure to draw the control flow determined by the compound predicate and the break. do { Char = getc(FP); NS++; if (Char >= ‘a’ && Char <= ‘z’) LC[Char] += 1; else if (Char <= 81) { NS = 0; break; } else NS--; } while (Char != EOF); Print_Stats(LC, NS); 2
ECE 3035 Computing Mechanisms Fall 2008 5 problems, 9 pages Final Exam 12 December 2008 Part B (12 points) Perform at least three standard compiler optimizations on the following C code fragment by writing the optimized version (in C) to the right. int foo(int a, int b) { int y = 16; int i, c, z = 0; for (i=0; i < 400; i++) { c = a/b +(z+10)*(z+10); z = bar(z*i, c*y); } return (z); } Briefly describe which standard compiler optimizations you applied: 3
ECE 3035 Computing Mechanisms Fall 2008 5 problems, 9 pages Final Exam 12 December 2008 Problem 2 (3 parts, 28 points) Associative Sets and Pointers Part A (10 points) Consider a hash table that uses 40 buckets , each containing an unsorted LIFO list of items. Inserted entries are appended to the end of the bucket list. Suppose the hash table contains 280 entries total and the entries are evenly distributed across the hash table buckets. Assume that computing the hash function takes an average of two operations and comparing two strings takes an average of twenty operations . Ignore effects of spatial and temporal reference locality. Suppose that 80% of keys looked up are found in the hash table and 20% are not found. How many of these operations would be required for the average lookup in the hash table described above? (show work) operations

#### You've reached the end of your free preview.

Want to read all 9 pages?

• Fall '08
• Staff
• MIPS architecture, Arithmetic shift, Logical shift, Mechanisms Final Exam