Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 559 Bytes

recursion.md

File metadata and controls

30 lines (19 loc) · 559 Bytes

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