if a 9 b0 c8 z 9 else z 17 ECE 3035 Computing Mechanisms Fall 2009 4 problems 6

# If a 9 b0 c8 z 9 else z 17 ece 3035 computing

This preview shows page 4 - 6 out of 6 pages.

if (!((a == 9) || (b>0)) && (c!=8)) z = 9; else z = 17;
ECE 3035 Computing Mechanisms Fall 2009 4 problems, 6 pages Exam One 16 September 2009 5 Problem 4 (4 parts, 22 points) Reverse Engineering Answer the following questions about the C code below. void Whatsit(char *File) { int Nums[100], NumNums, *Cur = Nums + 1, *Walk, Value; NumNums = Load_Mem(File, Nums); while (Cur < Nums + 100) { Value = *Cur; Walk = Cur; while (Walk > Nums && *(Walk-1) > Value) { *Walk = *(Walk-1); Walk--; } *Walk = Value; Cur++; } Part A (5 points) How many times does the statement Cur++ execute? Part B (9 points) When Load_Mem is executed, what do these pointers point to (e.g., at the 35 th element, beyond the 77 th element)? Nums Cur Nums + 100 Part C (4 points) Explain the effect of the following statement: *Walk = *(Walk-1); What does it accomplish in the context of the nested loop? Part D (4 points) What familiar algorithm does this code implement (be specific)?