Hello everyone...
Can someone help me convert the usual recursive floodfill function into iterative one? Just pseudocode is OK or the C-function would be better...
Btw, which problem that use floodfill function to solved/finished the problem? I need some... thanx for advance...
Flood Fill problem
Moderator: Board moderators
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
Re: Flood Fill problem
Some problems that can be solved using flood fill:Roby wrote:Btw, which problem that use floodfill function to solved/finished the problem? I need some... thanx for advance...
352 - The Seasonal War
469 - Wetlands of Florida
572 - Oil Deposits
657 - The die is cast
776 - Monkeys in a Regular Forest
782 - Contour Painting
784 - Maze Exploration
785 - Grid Colouring
830 - Shark
852 - Deciding victory in Go
10279 - Mine Sweeper
10336 - Rank the Languages
10592 - Freedom Fighter
10946 - You want what filled?
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
pseudocode for four direction flood-fill algorithm
iterative_floodfill(start_point)
{
- add to queue start_point
- while(length of queue > 0)
- get first element of queue -> qact
- fill this point
- for each direction in which you can go (up, down, left, right)
- check if you visited this point before
- if not => add this point to queue and check, that this point is visited
}
Of course if you know something more about filling, you can try filling in one step as many points as you can (filling for example all points to left and all points to right).
Best regards
DM
iterative_floodfill(start_point)
{
- add to queue start_point
- while(length of queue > 0)
- get first element of queue -> qact
- fill this point
- for each direction in which you can go (up, down, left, right)
- check if you visited this point before
- if not => add this point to queue and check, that this point is visited
}
Of course if you know something more about filling, you can try filling in one step as many points as you can (filling for example all points to left and all points to right).
Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Born from ashes - restarting counter of problems (800+ solved problems)
Re: Flood Fill problem
Where did you get the problems that weren't under Graphs in CP3 (Like 830 - shark)?angga888 wrote:Some problems that can be solved using flood fill:Roby wrote:Btw, which problem that use floodfill function to solved/finished the problem? I need some... thanx for advance...
352 - The Seasonal War
469 - Wetlands of Florida
572 - Oil Deposits
657 - The die is cast
776 - Monkeys in a Regular Forest
782 - Contour Painting
784 - Maze Exploration
785 - Grid Colouring
830 - Shark
852 - Deciding victory in Go
10279 - Mine Sweeper
10336 - Rank the Languages
10592 - Freedom Fighter
10946 - You want what filled?
Re: Flood Fill problem
Of course if you know something more about filling, you can try filling in one step as many points as you can (filling for example all points to left and all points to right).
GuL