

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Assignment; Professor: Choi; Class: Design & Analysis of Algorithm; Subject: Computer Science; University: George Washington University; Term: Spring 2009;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!
George Washington University Department of Computer Science Csci 212 - Homework 3
Due date: April 23, 2009 Email to bowuzh@gwmail.gwu.edu by 11:59PM or submit to CS Dept by 5PM.
10 Given an matrix of integers, you are to write a program that computes a path of minimal weight. A path starts anywhere in column 1 (the first column) and consists of a sequence of steps terminating in column n (the last column). A step consists of traveling from column i to column i+1 in an adjacent (horizontal or diagonal) row. The first and last rows (rows 1 and m) of a matrix are considered adjacent, i.e., the matrix “wraps” so that it represents a horizontal cylinder. For example, a move from cell (1, 1) to cell (m, 2) is legal. Legal steps are illustrated in Figure 1.
Figure 1:
The weight of a path is the sum of the integers in each of the n cells of the matrix that are visited. For example, two slightly different 5 × 6 matrices are shown in Figure 2 (the only difference is the numbers in the bottom row). The minimal path is illustrated for each matrix. Note that the path for the matrix on the right takes advantage of the adjacency property of the first and last rows. Design an dynamic programming algorithm to solve this problem.
Figure 2: