All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Queen Square II (Posted on 2006-11-22) Difficulty: 3 of 5
A few days after you paint the chess board in Queen Square, an admirer invites you to the Game Park, where he has a n x n square game board set up. Some of the squares have pieces on them, but most of them are empty. The admirer wants to completely paint some adjacent empty squares such that they form the largest empty square on the game board.

Given the game board as a binary grid with 1=piece and 0=no-piece, what is an O(nē) algorithm to find the largest empty square?

(The notation O(nē) refers to the algorithm speed for large n.)

No Solution Yet Submitted by Gamer    
Rating: 4.3333 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Some Thoughts re: Speedy check | Comment 2 of 4 |
(In reply to Speedy check by Federico Kereki)

Loading the full LD(i,j) array is an O(nē) process; if it was of a higher order, we couldn't use it.Assume LD(0...N,0...N) starts with zeroes.

for i=1 to N
    for j=1 to N
          LD(i,j)=GRID(i,j)
                +LD(i-1,j)
                +LD(i,j-1)
                -LD(i-1,j-1)


Edited on November 22, 2006, 2:05 pm
  Posted by Federico Kereki on 2006-11-22 14:04:26

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (11)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information