board coloring, JAVA Programming

Assignment Help:
write a java program to board coloring

Related Discussions:- board coloring

Execution process of java bytecode, Execution Process of Java bytecode ...

Execution Process of Java bytecode JVM are available for almost every operating system. Java bytecode is executed by employing any operating system's JVM. Hence achieve port

Page replacement algorithms code in nachos, what is the code for page repla...

what is the code for page replacement algorithms in nachos os

How does java allocate heap and stack memory?, Each time an object is start...

Each time an object is started in Java it goes into the area of memory named as heap. The primitive variables like double and int are allocated in the stack, if they are local inst

Application rewrite, Application Rewrite Project Description: There i...

Application Rewrite Project Description: There is an app that I want to be rewritten in order to support multiple profiles. The App is an OTP generator. It is required to

Write a note on random access files, Question 1 What are the different typ...

Question 1 What are the different types of data types in java? Question 2 Write a note on Operator Precedence Question 3 Write a note on Random access files

Android and universal ios- multipurpose testing app, Android and Universal ...

Android and Universal iOS, Multipurpose Testing App Universal iOS and Android, versatile Testing App Based on Phonegap with the subsequent main features * Support single answ

Assignment, For this Assignment, submit the following program: Create an ap...

For this Assignment, submit the following program: Create an application for an animal-fur trimming service. The business is open 15 weeks of the year, from April through July. The

How we declaring arrays in java language, How we Declaring Arrays in java l...

How we Declaring Arrays in java language? Like all other variables in Java, an array must have a exact type such as byte, int, String or double. Just variables of the appropria

Java conditional operator expression, Question: a) Change the following...

Question: a) Change the following example, using the Java's conditional operator expression, to solve the duplication problem. public class Demonstrate { public static voi

Need to modify joomla component, Project Description: I want to modify J...

Project Description: I want to modify Joomla component. Now there is Akeeba subscription component on this site. It works and the whole thing is fine, but there is no "teaser

diana

9/4/2012 4:23:49 AM



Board Coloring

Problem Description


In this problem you are given a board in which some of the elements are placed as shown in diagram below. Each element represents a color.
Fill the other elements in the board, such that none of the adjacent elements (vertically, horizontally and diagonally) should be of the same color.
Find out the minimum number of colors that should be used to fill the blank spaces in the board, so that the above condition is met.
Color representation is -: 0, 1, 2, 3, 4, 5, 6, 7…………………….
There is sample board:

For Example:

Given Board :

The matrix representation of board is :
[ _ 1 _ _ ]
[ 2 _ _ _ ]
[ _ _ 2 _ ]
[ 2 _ _ _ ]
In the above example the blank space is represented by ''_'' .
The minimum number of colors needed to fill the board in the example is 4.

Instruction to work with Open PBT Client:

Specify the work directory path in the ''Work Directory Path'' field. The path should correspond to your solution project directory.
Download the support files by clicking the Get Dev Files.
You will find the following three folders:
bin
src
lib
in your work directory.
Code the solution in . java file inside the src folder
All required files will be downloaded to your work directory. Creating additional files is strongly discouraged.

Step 1:
In your solution file:

Implement your logic in public int color(char[][] board) in class BoardColoring .
char[][] board : board is 2 dimensional matrix of order M X M where M = 4.

You can create more methods but, do it in the same class.

Step 2:
In your solution keep in mind the following constraints.

In this problem you have to write a program to find the minimum no of colors to fill a board where some of the elements of different color are already placed.
Method color() will take 2 D board as a input.
Method color() will return minimum no of colors which can fill the board with given condition.
The board should be a 2-dimensional M X M matrix, where M =4 otherwise return 0
Fill the other elements in the board, such that none of the adjacent elements (vertically, horizontally and diagonally) should be of the same color.

The Prototype of the method is:

public int color(char[][] board).
This method takes following arguments.

board is 2 dimensional matrix of order M X M where M = 4.

This method returns minimum no of color by which board can be filled.

The constraints are:

The board should be a 2-dimensional M X M matrix, where M =4 otherwise return 0
Fill the other elements in the board, such that none of the adjacent elements (vertically, horizontally and diagonally) should be of the same color.

Example 1
Input : { 2 0 _ 1 }
{ _ 1 _ _ }
{ _ 2 _ 0 }
{ _ _ _ 1 }
Output : 5

Explanation:
We need a minimum 5 different colors to complete the board.

Example 2
Input : { 2 0 _ 1 3}
{ _ 1 _ _ 2}
{ _ 2 _ 0 1}
{ _ _ _ 1 2}
{ _ _ _ _ 0}
Output : 0


Explanation:
Size of the board is greater than 4X4.

Example 3
Input : { _ 0 }
{ 1 _ }
Output : 0


Explanation:
Size of the board is less than 4X4.

For Java solutions
Package Name : test.boardcoloring
File Name : BoardColoring.java
Class Name : BoardColoring
Method Names : public int color(char[][] board)

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd