Skip to content

Latest commit

 

History

History
41 lines (26 loc) · 618 Bytes

recursion.md

File metadata and controls

41 lines (26 loc) · 618 Bytes
noatcards isdraft
true
false

Recursion

How to handle a recursive function that need to return a list


Input:

  • Result List
  • Current iteration element

Output: void

void f(List<String> result, String current) {
	// Do something
	result.add(...);
}

#recursion

How to handle a recursive function that need to return a maximum value


Implementation: return max(f(a), f(b))

#recursion

Loop inside of a recursive function?


Might be a code smell. The iteration is already brought by the recursion itself.

#recursion