Unformatted text preview: Computer Science 130B Winter 2007 Homework #4 Due: 4pm, March 14th, Wednesday NOTE: Even though this is not a programming assignment, the quickest way to answer some of these questions is to write a simple program. If you answer any of the questions using programming, please include a copy of your code with your written answers. Problem 1 Given an n × n chessboard, a knight is placed on an arbitrary square with coordinate ( x, y ). The problem is to determine n 2 1 knight moves such that every square is visited once if such a sequence of moves exists. Write an algorithm to solve this problem. Apply your algorithm to a chess board of size 8 × 8. Give the moves of the knight (if one exists), starting from the lower left corner (1 , 1). Problem 2 If you are given n men and n women and two n × n arrays P and Q such that P ( i, j ) is the preference of man i for woman j and Q ( i, j ) is the preference of woman i for man j . The preference is a coded as a zero or a positive number; the larger the number, the higher the preference. If mancoded as a zero or a positive number; the larger the number, the higher the preference....
View
Full Document
 Winter '08
 SURI
 Computer Science, Algorithms, Data Structures, state space tree

Click to edit the document details