CS 441/539 Homework 2 Practice Problems


Practice Problem 1

You are given a 4-row by n-column checkerboard with an integer printed on each square of the checkerboard. You are also given an unlimited number of pebbles where each pebble can be placed on exactly one square of the checkerboard.

A legal placement of pebbles is one in which no two pebbles are placed on horizontally or vertically adjacent squares. (Diagonal adjacencies are OK.) The value of the placement is the sum of the integers corresponding to the squares that are covered by pebbles of that placement. Give the most efficient algorithm you can for computing a placement of maximum value.

Hint: You may use the fact that the number of legal patterns of pebbles that can occur in any one column is eight. You may also talk about two columns being consistent if they do not have pebbles in the same row.


Practice Problem 2

Let S be a sequence of n (unordered) integers. Give an algorithm to find then longest non-decreasing (i.e. sorted from smallest to largest) subsequence of S.