sp08-sl-s2 - ECE 3035 A B 4 problems 5 pages Problem 1(3 parts 22 points Computing Mechanisms Exam Two Solutions Spring 2008 9 April 2008 Path Search

sp08-sl-s2 - ECE 3035 A B 4 problems 5 pages Problem 1(3...

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

ECE 3035 A & B Computing Mechanisms Spring 2008 4 problems, 5 pages Exam Two Solutions 9 April 2008 1 Problem 1 (3 parts, 22 points) Path Search Part A (6 points) The diamond search map above list the cost of visiting each square (in black) and the position of the square (in blue). Answer the following questions (show work). Cost to square 55 47 – 38 + 89 – 79 + 60 = 79 Cost to square 48 -75 + 37 = -38 Cost to square 25 -75 + 37 – 90 – 79 – 74 = -281 Part B (11 points) Write a MIPS subroutine that computes (in general) the path cost from the starting square to square 115. Assume $3 is initialized to the address of square 71. Return the path cost in register $2. label instruction comment CostTo115: addi $5, $0, 4 # count equals run - 1 lw $2, Array($3) # load initial weight Loop: add $3, $3, 44 # adjust for next square lw $1, Array($3) # load weight add $2, $2, $1 # add to sum addi $5, $5, -1 # next loop? bne $5, $0, Loop # loop until done jr $31 # return to caller Part C (5 points) Explain the flaw in creating a minimum cost path search program with no limits on path length. If the path length is unbound, the search algorithm will enter an infinite loop stepping in and out of negative squares as the cost moves towards negative infinity.
Image of page 1
ECE 3035 A & B Computing Mechanisms Spring 2008 4 problems, 5 pages Exam Two Solutions 9 April 2008 2 Problem 2 (2 parts, 30 points) Activation Frames Consider the following C fragment: int main() { int X = 100, Y = 255, Z = 1, A[] = {3, 5, 7}; int Foo(int, int *, int *); Z = Foo(X, &Y, A); printf("X = %d, Y = %d, A[0]=%d, A[1]=%d, A[2]=%d\n", X, Y, A[0], A[1], A[2]); return (Y); } int Foo(int P, int *Q, int V[]) { int Z = 35, W[] = {2, 4};
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 5 pages?

  • Fall '08
  • Staff
  • Subroutine, Void type, Garbage collection, addr value addr, value addr value

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes