Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A Sudoku puzzle uses a 9*9 grid in which each column and row, as well as each of the nine 3 *3 subgrids, must contain

A Sudoku puzzle uses a 9*9 grid in which each column and row, as well as each of the nine 3 *3 subgrids, must contain all of the digits 1 9. Figure below presents an example of a valid Sudoku puzzle. This project consists of designing a multithreaded application that determines whether the solution to a Sudoku puzzle is valid.

I made this is Java:

int[][] mat = { { 6, 2, 4, 5, 3, 9, 1, 8, 7 }, { 5, 1, 9, 7, 2, 8, 6, 3, 4 }, { 8, 3, 7, 6, 1, 4, 2, 9, 5 }, { 1, 4, 3, 8, 6, 5, 7, 2, 9 }, { 9, 5, 8, 2, 4, 7, 3, 6, 1 }, { 7, 6, 2, 3, 9, 1, 4, 5, 8 }, { 3, 7, 1, 9, 5, 6, 8, 4, 2 }, { 4, 9, 6, 1, 8, 2, 5, 7, 3 }, { 2, 8, 5, 4, 7, 3, 9, 1, 6 } };

There are several different ways of multithreading this application. The one suggested strategy is to create threads that check the following criteria: A thread to check that each column contains the digits 1 through 9 A thread to check that each row contains the digits 1 through 9 Nine threads to check that each of the 3*3 subgrids contains the digits 1 through 9

The parent thread will create the worker threads, passing each worker the location that it must check in the Sudoku grid. This step will require passing several parameters to each thread

Each worker thread is assigned the task of determining the validity of a particular region of the Sudoku puzzle. Once a worker has performed this check, it must pass its results back to the parent. One good way to handle this is to create an array of integer values that are visible to each thread. The ith index in this array corresponds to the ith worker thread. If a worker sets its corresponding value to 1, it is indicating that its region of the Sudoku puzzle is valid. A value of 0 indicates otherwise. When all worker threads have completed, the parent thread checks each entry in the result array to determine if the Sudoku puzzle is valid

It is to be completed in Java or C using pthreads, and originally did it in Java but it is not quite working and I do not know how to do the worker threads using the Fork-Join, I would appreciate any solution to help me.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Why have the number of major economic strikes in the U.S. declined?

Answered: 1 week ago