Question: need for this Pseudo Code to be fleshed out. Has to be done using C++ syntax and language create an empty queue; for (each water
need for this Pseudo Code to be fleshed out. Has to be done using C++ syntax and language
create an empty queue; for (each water source at or below the water level) { flood that square; add that square to the queue; } while (the queue is not empty) { dequeue a position from the front of the queue; for (each square adjacent to the position in a cardinal direction) { if (that square is at or below the water level and isn't yet flooded) { flood that square; add that square to the queue; } } } create an empty queue; for (each water source at or below the water level) { flood that square; add that square to the queue; } while (the queue is not empty) { dequeue a position from the front of the queue; for (each square adjacent to the position in a cardinal direction) { if (that square is at or below the water level and isn't yet flooded) { flood that square; add that square to the queue; } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
