int num; for (int i = 0; i < SRN; i++) { for (int j = 0; j < SRN; j++) { do { num= randomGenerator (N); } while (!unusedInBox(row, col, num)); mat[row + i][col + j] = num; // Random generator int randomGenerator (int num) { return (int) floor( (float) (rand() / double (RAND_MAX) num + 1)); // Check if safe to put in cell bool CheckIfSafe (int i, int j, int num) { return ( unUsed InRow(1, num) && unUsedInCol(j, num) && unusedInBox(i - i % SRN, j - j % SRN, num)); check in the row for existence bool unusedInRow(int i, int num) { for (int j = 0; j < N; j++) { if (mat[i][j] == num) { return false; } return true; // check in the row for existence bool unusedInCol(int j, int num) { for (int i = 0; i < N; i++) { if (mat[i][j] == num) { return false; } return true; // A recursive function to fill remaining // matrix bool fillRemaining(int i, int j) { // System.out.println(i+""+j); if (1 >= N && i < N-1) { i=i+1; j = 0; if (i >= N && j >= N) { return true; if (1 < SRN) { if (1 < SRN) { - SRN; } else if (i < N - SRN) { if (1 = (int) (1/SRN) • SRN) { j=j+SRN; } else { if (1 == N - SRN) { 1=1+1; j = 0; if (1 >= N) { return true; for (int num= 1; num < N; num++) { if (checkIfSafe(i, j, num)) { + 1)) { mat[1][1] = num; if (fillRemaining(1, return true; } mat[i][j] = 0;
int num; for (int i = 0; i < SRN; i++) { for (int j = 0; j < SRN; j++) { do { num= randomGenerator (N); } while (!unusedInBox(row, col, num)); mat[row + i][col + j] = num; // Random generator int randomGenerator (int num) { return (int) floor( (float) (rand() / double (RAND_MAX) num + 1)); // Check if safe to put in cell bool CheckIfSafe (int i, int j, int num) { return ( unUsed InRow(1, num) && unUsedInCol(j, num) && unusedInBox(i - i % SRN, j - j % SRN, num)); check in the row for existence bool unusedInRow(int i, int num) { for (int j = 0; j < N; j++) { if (mat[i][j] == num) { return false; } return true; // check in the row for existence bool unusedInCol(int j, int num) { for (int i = 0; i < N; i++) { if (mat[i][j] == num) { return false; } return true; // A recursive function to fill remaining // matrix bool fillRemaining(int i, int j) { // System.out.println(i+""+j); if (1 >= N && i < N-1) { i=i+1; j = 0; if (i >= N && j >= N) { return true; if (1 < SRN) { if (1 < SRN) { - SRN; } else if (i < N - SRN) { if (1 = (int) (1/SRN) • SRN) { j=j+SRN; } else { if (1 == N - SRN) { 1=1+1; j = 0; if (1 >= N) { return true; for (int num= 1; num < N; num++) { if (checkIfSafe(i, j, num)) { + 1)) { mat[1][1] = num; if (fillRemaining(1, return true; } mat[i][j] = 0;
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Please answer fast
Need this code in java
![80
81
82
83
84
85
86
87
88
89
98
91
92
93
94
95
96
97
98
99
100
101
102
103
184
105
106
187
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
{
int num;
for (int i = 0; i < SRN; i++) {
for (int j = 0; j < SRN; j++) {
do {
}
num= randomGenerator (N);
} while (!unUsed InBox(row, col, num));
mat[row + i][col + j] = num;
}
}
// Random generator
int randomGenerator(int num)
{
return (int) floor(
(float) (rand() / double (RAND_MAX) * num + 1));
}
// Check if safe to put in cell
bool CheckIfSafe(int i, int j, int num)
{
return (
unUsedInRow(1, num) && unUsed InCol(j, num)
&& unUsed InBox(i - i % SRN, j - j % SRN, num));
}
// check in the row for existence
bool unUsedInRow(int i, int num)
{
for (int j = 0; j<n; j++){
if (mat[i][j] == num) {
return false;
}
}
return true;
}
// check in the row for existence
bool unUsedInCol(int j, int num)
{
for (int i = 0; i < N;i++) {
if (mat[i][j] == num) {
return false;
}
}
return true;
}
// A recursive function to fill remaining
// matrix
bool fillRemaining (int i, int j)
{
// System.out.println(i+" "+j);
if (j >= N && 1 < N - 1) {
i = 1 + 1;
j = 0;
}
if (i >= N && j >= N) {
return true;
}
if (i < SRN) {
if (j< SRN) {
j = SRN;
}
}
else if (i < N - SRN) {
if (j== (int) (i / SRN) * SRN) {
j=j + SRN;
}
}
else {
if (j== N SRN) {
i=i+1;
j = 0;
if (i >= N) {
}
return true;
}
for (int num= 1; num <= N; num++) {
if (CheckIfSafe(i, j, num)) {
mat[i][j] = num;
if (fillRemaining(i, j + 1)) {
return true;
}
mat[i][j] = 0;](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F1ef669d6-f671-4cb9-b054-2eac267ce3b4%2F337a1e31-f2f9-4881-878d-6c9f917c7f04%2Fg51ju4g_processed.png&w=3840&q=75)
Transcribed Image Text:80
81
82
83
84
85
86
87
88
89
98
91
92
93
94
95
96
97
98
99
100
101
102
103
184
105
106
187
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
{
int num;
for (int i = 0; i < SRN; i++) {
for (int j = 0; j < SRN; j++) {
do {
}
num= randomGenerator (N);
} while (!unUsed InBox(row, col, num));
mat[row + i][col + j] = num;
}
}
// Random generator
int randomGenerator(int num)
{
return (int) floor(
(float) (rand() / double (RAND_MAX) * num + 1));
}
// Check if safe to put in cell
bool CheckIfSafe(int i, int j, int num)
{
return (
unUsedInRow(1, num) && unUsed InCol(j, num)
&& unUsed InBox(i - i % SRN, j - j % SRN, num));
}
// check in the row for existence
bool unUsedInRow(int i, int num)
{
for (int j = 0; j<n; j++){
if (mat[i][j] == num) {
return false;
}
}
return true;
}
// check in the row for existence
bool unUsedInCol(int j, int num)
{
for (int i = 0; i < N;i++) {
if (mat[i][j] == num) {
return false;
}
}
return true;
}
// A recursive function to fill remaining
// matrix
bool fillRemaining (int i, int j)
{
// System.out.println(i+" "+j);
if (j >= N && 1 < N - 1) {
i = 1 + 1;
j = 0;
}
if (i >= N && j >= N) {
return true;
}
if (i < SRN) {
if (j< SRN) {
j = SRN;
}
}
else if (i < N - SRN) {
if (j== (int) (i / SRN) * SRN) {
j=j + SRN;
}
}
else {
if (j== N SRN) {
i=i+1;
j = 0;
if (i >= N) {
}
return true;
}
for (int num= 1; num <= N; num++) {
if (CheckIfSafe(i, j, num)) {
mat[i][j] = num;
if (fillRemaining(i, j + 1)) {
return true;
}
mat[i][j] = 0;
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 5 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education