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
icon
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;
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
steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Array
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education