From 7d436ad9a2e12b7bf0cdafb230a034b9ffb5cb66 Mon Sep 17 00:00:00 2001 From: Libkyy Date: Wed, 1 Jun 2022 18:05:03 +0200 Subject: [PATCH] Commenting code --- src/RecipeTree.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/RecipeTree.java b/src/RecipeTree.java index f08bf1a..402f24e 100644 --- a/src/RecipeTree.java +++ b/src/RecipeTree.java @@ -24,15 +24,18 @@ public class RecipeTree } public void DFS(RecipeNode node, String value) { + //Base case where we stop recursion if(node == null) { - System.out.println("Node not found"); + System.out.println("Node not found, going back up"); return; } + //Case where its actually found !!!! if(node.getIngredient().equals(value)) { System.out.println(node.getIngredient() + " " + node.getPortion()); } + //Depth first search we take first child then we take the first child in the first child then we take the first child in the first child in the first child for(RecipeNode child : node.getChildren()) { DFS(child, value);