Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contents/flood_fill/code/java/flood_fill.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package code.java;public class flood_fill {
}
10 changes: 10 additions & 0 deletions contents/flood_fill/flood_fill.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ In code, this might look like this:
[import:10-25, lang="python"](code/python/flood_fill.py)
{% sample lang="coco" %}
[import:15-20, lang="coconut"](code/coconut/flood_fill.coco)
{% sample lang="java" %}
[import:17-32, lang="java"](code/java/flood_fill.java)
{% endmethod %}


Expand All @@ -118,6 +120,8 @@ In code, it might look like this:
[import:55-63, lang="python"](code/python/flood_fill.py)
{% sample lang="coco" %}
[import:52-61, lang:"coconut"](code/coconut/flood_fill.coco)
{% sample lang="java" %}
[import:45-51, lang="java"](code/java/flood_fill.java)
{% endmethod %}

The above code continues recursing through available neighbors as long as neighbors exist, and this should work so long as we are adding the correct set of neighbors.
Expand All @@ -135,6 +139,8 @@ Additionally, it is possible to do the same type of traversal by managing a stac
[import:27-36, lang="python"](code/python/flood_fill.py)
{% sample lang="coco" %}
[import:23-34, lang:"coconut"](code/coconut/flood_fill.coco)
{% sample lang="java" %}
[import:33-44, lang="java"](code/java/flood_fill.java)
{% endmethod %}

This is ultimately the same method of traversal as before; however, because we are managing our own data structure, there are a few distinct differences:
Expand Down Expand Up @@ -180,6 +186,8 @@ The code would look something like this:
[import:38-53, lang="python"](code/python/flood_fill.py)
{% sample lang="coco" %}
[import:36-49, lang:"coconut"](code/coconut/flood_fill.coco)
{% sample lang="java" %}
[import:52-63, lang="java"](code/java/flood_fill.java)
{% endmethod %}

Now, there is a small trick in this code that must be considered to make sure it runs optimally.
Expand Down Expand Up @@ -264,6 +272,8 @@ After, we will fill in the left-hand side of the array to be all ones by choosin
[import:, lang="python"](code/python/flood_fill.py)
{% sample lang="coco" %}
[import, lang="coconut"](code/coconut/flood_fill.coco)
{% sample lang="java" %}
[import, lang="java"](code/java/flood_fill.java)
{% endmethod %}


Expand Down