6ehw2 - minimum number of scalar multiplications needed to...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
National Taiwan University Handout #9 Department of Electrical Engineering October 29, 2009 Algorithms, Fall 2009 Yao-Wen Chang Name: Student ID: Web ID: Problem 1. (24 pts total) Given four matrices A 1 ,A 2 ,A 3 ,A 4 of dimensions 3 × 1 , 1 × 2 , 2 × 5 , 5 × 7, respectively. (a) (18 pts) Fill every field in the m and s tables, where m [ i,j ] gives the minimum number of scalar multiplications needed to compute A i A i +1 ...A j and s [ i,j ] records the value of k such that the optimal parenthsization of A i A i +1 ...A j splits the product between A k and A k +1 . (a) (6 pts) Find an optimal parenthesization of the matrix-chain product A 1 A 2 A 3 A 4 and give the
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: minimum number of scalar multiplications needed to compute the chain. Problem 2. (24 pts total) The figure below shows a binary tree. (a) (8 pts) Label the tree with numbers from the set { 1 , 2 , 4 , 5 , 6 , 7 , 8 } so that it is a legal binary search tree. (b) (8 pts) Label each node in the tree with R or B denoting the respective colors RED and BLACK so that the tree is a legal red-black tree. (c) (8 pts) Give the red-black tree that results from inserting the key 3 into the tree of (b)....
View Full Document

Ask a homework question - tutors are online