Data Structures and Algorithms

muigai unaka

Week 5

Recursion

  • Looping without a loop statement
  • A function that is included in it's own body
  • Requires a "base case" or terminating condition for exiting the recursion

Recursive functions repeat a process

by calling itself

  • Each call takes up more time and space
  • Each call pushes the function values, local variables, parameters and return statement values on to the call stack

Recursion

In general, recursion should be used when it produces a cleaner, more expressive solution compared to the iterative solution. Also, be sure that an excessive number of recursive calls will either not occur, or not lead to performance issues such as stack overflow.

Recursion vs Iteration?

الأسئلة?

(al'asyila)

Dynamic Programming

Dynamic Programming requires you break down an optimization problem into simpler sub-problems, and store the solution to each sub-problem so that each sub-problem is only solved once

Dynamic Programming

Problems that seek the maximum or minimum solution given certain constraints. Dynamic Programming looks through all possible sub-problems and never recomputes the solution to any sub-problem.

Optimization Problems

Memoization vs Tabulation

Leetcode Problems

lanndaale?

Data Structures and Algorithms Week 5

By Muigai Unaka

Data Structures and Algorithms Week 5

Data Structures and Algorithms week 5 at Resilient Coders. Algorithms II: Recursion, Backtracking, Dynamic Programming and Greedy Algorithms

  • 394