[Solved] Algorithm for a Recursive function for a ArrayList and when a arrayList is empty return the exact array [closed]

If I understand correctly what you’re asking, something like this should satisfy it, but please note that recursion is not really the best way to achieve what you’re apparently trying to do: public static void count(ArrayList<Double> list) { if (list.empty()) { return; // or consider using if/else } double total = total(list); if (total>100) { … Read more

[Solved] Trying to solve recursion in Python

tl;dr; The method defined is recursive, you can call it enough times to force an Exception of type Recursion Error because it adds to the stack every time it calls itself. Doesn’t mean it’s the best approach though. By definition a recursive function is one that is meant to solve a problem by a finite … Read more

[Solved] Minesweeper revealing cells in C

Okay, here’s an example implementation. It uses the following values for tiles: 0 to 8: an unmined tile; the number represents the pre-calculated number of adjacent mines 9: a mine; this special value is defined as BOMB. Covered tiles have 10 added to that, flagged tiles (not used here) have 20 added to that. You … Read more

[Solved] Maximum tree depth in Haskell

You would want to write a recursive function to do this. For each Tree constructor, you’ll need a different case in your function. To start with, you know that the depth of any Leaf is 1, so maxDepth :: Tree -> Int maxDepth (Leaf _) = 1 maxDepth (Branch2 c left right) = maximum [???] … Read more