CSE548, AMS542: Analysis of Algorithms, Fall 2016 Date: Sep 25. Homework #1. ( Due: Oct 10 ) Figure 1: The laser game.

Similar documents
ProCo 2017 Advanced Division Round 1

18.S34 (FALL, 2007) PROBLEMS ON PROBABILITY

Words Mobile Ready Game Documentation

BMT 2018 Combinatorics Test Solutions March 18, 2018

2048: An Autonomous Solver

AI Approaches to Ultimate Tic-Tac-Toe

Chapter 4 Number Theory

2015 ACM ICPC Southeast USA Regional Programming Contest. Division 1

Senior Math Circles February 10, 2010 Game Theory II

MAS336 Computational Problem Solving. Problem 3: Eight Queens

Solution Algorithm to the Sam Loyd (n 2 1) Puzzle

Eleventh Annual Ohio Wesleyan University Programming Contest April 1, 2017 Rules: 1. There are six questions to be completed in four hours. 2.

The Eighth Annual Student Programming Contest. of the CCSC Southeastern Region. Saturday, November 3, :00 A.M. 12:00 P.M.

3. Transportation Problem (Part 2)

Inside Outside Circles Outside Circles Inside. Regions Circles Inside Regions Outside Regions. Outside Inside Regions Circles Inside Outside

LUNDA DESIGNS by Ljiljana Radovic

Second Annual University of Oregon Programming Contest, 1998

CS188 Spring 2010 Section 3: Game Trees

Organization Team Team ID# If each of the congruent figures has area 1, what is the area of the square?

17. Symmetries. Thus, the example above corresponds to the matrix: We shall now look at how permutations relate to trees.

Question Score Max Cover Total 149

GENERALIZATION: RANK ORDER FILTERS

AI Plays Yun Nie (yunn), Wenqi Hou (wenqihou), Yicheng An (yicheng)

TASK NOP CIJEVI ROBOTI RELJEF. standard output

Problem F. Chessboard Coloring

Graphs of Tilings. Patrick Callahan, University of California Office of the President, Oakland, CA

WPF PUZZLE GP 2018 ROUND 7 INSTRUCTION BOOKLET. Host Country: Netherlands. Bram de Laat. Special Notes: None.

SUDOKU1 Challenge 2013 TWINS MADNESS

Monte Carlo based battleship agent

Nested Monte-Carlo Search

Week 1. 1 What Is Combinatorics?

OCTAGON 5 IN 1 GAME SET

Adversary Search. Ref: Chapter 5

CS188 Spring 2010 Section 3: Game Trees

Problem A: Complex intersecting line segments

mywbut.com Two agent games : alpha beta pruning

Classwork Example 1: Exploring Subtraction with the Integer Game

Exploring Concepts with Cubes. A resource book

Design of Parallel Algorithms. Communication Algorithms

LESSON 2: THE INCLUSION-EXCLUSION PRINCIPLE

The 2017 British Informatics Olympiad

Two Parity Puzzles Related to Generalized Space-Filling Peano Curve Constructions and Some Beautiful Silk Scarves

Episode 3 16 th 19 th March Made In India and Regions by Prasanna Seshadri

STRATEGY AND COMPLEXITY OF THE GAME OF SQUARES

Project Connect Four (Version 1.1)

Assignment 6 Play A Game: Minesweeper or Battleship!!! Due: Sunday, December 3rd, :59pm

Introduction Solvability Rules Computer Solution Implementation. Connect Four. March 9, Connect Four 1

Kenken For Teachers. Tom Davis January 8, Abstract

Color-matching Non-matching Symmetries Patterns Game

The 2013 British Informatics Olympiad

The 2015 British Informatics Olympiad

Unit 12: Artificial Intelligence CS 101, Fall 2018

2359 (i.e. 11:59:00 pm) on 4/16/18 via Blackboard

Tetris: A Heuristic Study

Jamie Mulholland, Simon Fraser University

LEARNING ABOUT MATH FOR K TO 5. Dorset Public School. April 6, :30 pm 8:00 pm. presented by Kathy Kubota-Zarivnij

Part III F F J M. Name

The first player to construct his or her obelisk is the winner, and if a player has no legal moves, he or she immediately loses the game.

Problem Set 4 Due: Wednesday, November 12th, 2014

Spring 06 Assignment 2: Constraint Satisfaction Problems


Spring 06 Assignment 2: Constraint Satisfaction Problems

I.M.O. Winter Training Camp 2008: Invariants and Monovariants

Permutations. = f 1 f = I A

Chapter 4 Heuristics & Local Search

CS61B, Fall 2014 Project #2: Jumping Cubes(version 3) P. N. Hilfinger

Easy Games and Hard Games

Partitions and Permutations

Algorithmique appliquée Projet UNO

MATLAB Image Processing Toolbox

Lecture 2: Problem Formulation

ISudoku. Jonathon Makepeace Matthew Harris Jamie Sparrow Julian Hillebrand

CSC 380 Final Presentation. Connect 4 David Alligood, Scott Swiger, Jo Van Voorhis

Heuristic Search with Pre-Computed Databases

1. Rectangles 20 points

How Many Mates Can a Latin Square Have?

ENGR170 Assignment Problem Solving with Recursion Dr Michael M. Marefat

Techniques for Generating Sudoku Instances

Digital Image Processing. Lecture # 6 Corner Detection & Color Processing

CMPUT 657: Heuristic Search

Reflections on the N + k Queens Problem

Edge-disjoint tree representation of three tree degree sequences

CSE 573 Problem Set 1. Answers on 10/17/08

The Mathematics of Playing Tic Tac Toe

MATHEMATICS ON THE CHESSBOARD

CSE 21 Practice Final Exam Winter 2016

arxiv: v1 [math.co] 12 Jan 2017

The patterns considered here are black and white and represented by a rectangular grid of cells. Here is a typical pattern: [Redundant]

Overview. Equipment. Setup. A Single Turn. Drawing a Domino

a b c d e f g h i j k l m n

N-Queens Problem. Latin Squares Duncan Prince, Tamara Gomez February

MAT 409 Semester Exam: 80 points

Analyzing Games: Solutions

Pay attention to how flipping of pieces is determined with each move.

Wordy Problems for MathyTeachers

If a word starts with a vowel, add yay on to the end of the word, e.g. engineering becomes engineeringyay

Learning to Play like an Othello Master CS 229 Project Report. Shir Aharon, Amanda Chang, Kent Koyanagi

2014 ACM ICPC Southeast USA Regional Programming Contest. 15 November, Division 1

Name: Final Exam May 7, 2014

STAJSIC, DAVORIN, M.A. Combinatorial Game Theory (2010) Directed by Dr. Clifford Smyth. pp.40

Transcription:

CSE548, AMS542: Analysis of Algorithms, Fall 2016 Date: Sep 25 Homework #1 ( Due: Oct 10 ) Figure 1: The laser game. Task 1. [ 60 Points ] Laser Game Consider the following game played on an n n board, where n = 2 k for some integer k 0 (see Figure 1). There are three (3) types of game pieces: Generators. A laser beam generator is placed to the left of each row which generates and directs a laser beam of one of the following colors horizontally to the right: red (r), green (g), blue (b), yellow (y) and violet (v). Each generator is worth some points [1, 100]. The number of available generators is n g n, but only n of them can be used during any given game. Receptors. At the top of each column a laser receptor is placed which is activated when a laser beam of a specific color (i.e., r/g/b/y/v) hits its sensor. Each receptor is also worth some points [1, 100]. During any given game exactly n receptors must be chosen for use from a set of n r n available receptors. 1

Deflector. The beam deflector moves through the grid. When it is placed inside a grid cell its mirror surface must be placed on a cell-diagonal so that it faces the top-left corner of that cell. When a horizontal laser beam hits the deflector the beam changes direction and moves upward and hits the receptor placed at the top of the column. Only one (1) deflector is available. Game Rules. 1. For every row on the board choose a generator uniformly at random from the set of available generators and place it to the left of the row facing horizontally to the right. 2. For every column on the board choose a receptor uniformly at random from the set of available receptors and place it at the top of the column facing vertically downward. 3. The deflector is initially placed inside the cell at the bottom-right corner of the grid. 4. At each step of the play the deflector must be moved to a neighboring cell either to the left or above or diagonally to the top-left of the current cell. 5. The game ends when the deflector reaches the top-left corner cell of the grid. 6. When inside a cell the deflector deflects the beam it receives from the beam generator placed to its left on the same row so that the beam hits the receptor placed at the top of the column. If the deflected laser has the right color (i.e., has the color that the receptor can accept), the receptor is activated. 7. As soon as a receptor becomes activated both that receptor and the activating generator are removed from the board and the player collects all points associated with them. 8. The deflector must never be on an empty row (i.e., without a generator) or column (i.e., without a reflector). 9. The player s goal is to move the deflector from the bottom-right corner of the grid to the top-left corner in a way that maximizes the total number of points he can collect. Figure 1 shows an example game on an 8 8 game board. The path taken by the deflector allows the player to collect (9 + 3) + (1 + 7) + (8 + 2) = 30 points which is not necessarily the highest possible score on this board. Now please answer the following questions. (a) [ 20 Points ] Given an initial state of the board with all generators and receptors are chosen and placed and the deflector at the bottom-right corner, explain how in Θ ( n 2) time and space you can find a best deflector path, i.e., a deflector path that maximizes the total number of points collected by the player. (b) [ 5 Points ] Explain how you can generalize your algorithm from part (a) to use Θ ( n 1+ɛ) space and run in time Θ ( n 3 ɛ) for any given ɛ [0, 1]. Observe that when ɛ = 0, this algorithm uses Θ (n) space, but runs in Θ ( n 3) time. (c) [ 35 Points ] Design a recursive divide-and-conquer algorithm to find the best deflector path in Θ ( n 2) time and Θ (n) space Find and solve the recurrences for running time and space usage. 2

Task 2. [ 50 Points ] A Game of Polyominoes In this task we will consider a game of polyominoes played by two (2) players (red and green) on an n n square board, where n = 2 k for some integer k 0. Each game piece is a polyomino which is nothing but a tile that can exactly cover a finite connected subset of the square cells of the game board. In other words, each game piece is a geometric figure formed by putting one or more square cells edge to edge, where each cell is exactly equal to a cell of the board. Each such polyomino will be composed of m [1, n 2 ] square cells, and must also completely fit inside the game board. Figure 2 shows an example. (a) Game board (b) Game pieces (each piece comes in both red and green) Figure 2: An example 8 8 game board with three (3) types of game pieces (i.e., polyominoes). Each square of the game board has a number written on it which is the number of points a player wins if she can occupy that cell using one of her game pieces (e.g., see Figure 2(a)). Initially, the board is empty (i.e., no one occupies any of its cells), and both players have exactly the same set of polyominoes (i.e., one red set and one green set). Figure 3: Each game piece can be used in one of four (4) orientations. The red player makes the first move, and then the two players take turns in making the moves. In her turn a player covers a subset of unoccupied cells using one of her game pieces. The newly placed polyomino must not cover an already occupied cell. Though the entire polyomino does not need to 3

be placed completely inside the board, it must cover at least one board cell. All four orientations of a polyomino that keep its sides parallel to the sides of the board are legal (see Figure 3). The game ends as soon as either both players run out of game pieces or one of the players fails to make a legal move. When the game ends each player adds up all points written on the cells she has occupied, and the player with the higher total score wins. Figure 4 shows an example game in which red wins with 136 points while green scores only 84 points. (a) after red s first move (c) after red s second move (e) after red s third move (b) after green s first move (d) after green s second move (f) after green s third move Figure 4: State of the game board after each move made by the players on the game board shown in Figure 2(a) using the game pieces shown in Figure 2(b). Now please answer the following questions. (a) [ 10 Points ] Suppose you are given an n n polyomino game board with a number written on each cell, where n = 2 k for some integer k 0. Some of the cells of the board are marked as occupied as a result of moves already made by the players. You are also given a polyomino that the player who is going to make the next move is planning to use. The polyomino can have anywhere between 1 and n 2 square cells, but completely fits inside the game board. You are asked to help the player by finding a location on the board where this game piece can be legally placed and in what orientation so that the total number of points in all cells covered by it is maximized. Show that this problem can be trivially solved in O ( n 4) time. (b) [ 40 Points ] Show that the problem given in part (a) can be solved in O ( n 2 log n ) time. 4

Task 3. [ 70 Points ] Multiplying Fractal Matrices In this task we will consider matrices in which some of the entries are guaranteed to be zeros, and the cells that may contain nonzero entries form a fractal shape. We will call them fractal matrices. We will only consider square matrices, and assume that for each such n n matrix n will be a power of 2, i.e., n = 2 k for some integer k 1. Row and column numbers will be from 0 to n 1. The following two types of fractal matrices will be used. -Fractal. nonzero. A cell (i, j) will definitely contain a zero provided the bitwise AND of i and j is -Fractal. A cell (i, j) will definitely contain a zero provided the bitwise AND of (n i 1) and (n j 1) is nonzero. We will analyze running times of the three matrix multiplication algorithms we have seen in the class, namely the standard iterative algorithm, the standard recursive algorithm and Strassen s algorithm, for computing products XY, where X is a -fractal matrix and Y is either a -fractal or a -fractal or a standard matrix. The major question we will ask is if Strassen s algorithm is still asymptotically faster than the other two algorithms. (a) [ 5 Points ] Draw -fractal matrices of sizes 2 2, 4 4, 8 8 and 16 16, and only mark the cells that are not guaranteed to be zeros leaving all other cells empty. Do the same for -fractal matrices. (b) [ 5 Points ] If X is an n n -fractal matrix and Y is an n n standard matrix, what is the running time of the standard recursive algorithm for computing XY? (c) [ 10 Points ] How will you modify the layout of the matrices so that the standard iterative algorithm can compute the product in part (b) within the same asymptotic time bound as the standard recursive algorithm? (d) [ 10 Points ] What will be the running time of Strassen s algorithm for computing the product in part (b)? (e) [ 20 Points ] Repeat parts (b) (d) assuming Y to be another n n -fractal matrix. (f) [ 20 Points ] Repeat parts (b) (d) assuming Y to be an n n -fractal matrix. 5