QB3 - Dynamic Programming

QB3 - Dynamic Programming - COMP 271 Design and Analysis of...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: COMP 271 Design and Analysis of Algorithms 2004 Fall Semester Question Bank 3 Solving these questions will give you good practice for the midterm exam. Some of these questions (or similar ones) will definitely appear on your exam! Note that you do not have to submit answers to these questions for grading. Your TAs will discuss answers to selected questions in the tutorials. 1. Recall that in the matrix-chain multiplication problem, we are given a sequence A 1 ,A 2 ,...,A n of n matrices, where A i has size p i − 1 × p i . The goal is to determine the least number of scalar multiplications needed to compute the matrix chain product, A 1 A 2 ...A n . (a) Let m ( i,j ) denote the least cost of multiplying matrices A i ...A j , where j ≥ i . In class we wrote a recurrence relation for m ( i,j ). This recurrence relation can be directly translated into a recursive function that takes two arguments, i and j . Draw a recursion tree to show what recursive calls result when this function is called with arguments i = 3 and j = 6, respectively. (b) By looking at the recursion tree of part (b), give two examples of subproblems which are being solved more than once. (c) Give an intuitive explanation as to why the purely recursive approach is inef- ficient for solving this problem. (Answer in just two lines.) (d) Dynamic programming can be used to solve this problem much faster than the purely recursive approach. Give the basic idea of this method, clearlythe purely recursive approach....
View Full Document

This note was uploaded on 10/18/2009 for the course COMP 271 taught by Professor Arya during the Spring '07 term at HKUST.

Page1 / 3

QB3 - Dynamic Programming - COMP 271 Design and Analysis of...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online