Skip to content

Latest commit

 

History

History
18 lines (11 loc) · 547 Bytes

File metadata and controls

18 lines (11 loc) · 547 Bytes

Recursion-javascript

  • The Fibonacci Sequence (using both iterative and recursive methods)
  • Merge Sort (a recursive sorting algorithm)

Solutions

Fibonacci Sequence

  1. Using iteration

    • Starts with [0, 1] and keeps adding the last two numbers until length n.
  2. Using recursion

    • Builds the sequence by recursively generating fibsRec(n - 1) and adding the last two numbers to the end.

Merge Sort

  • Recursively splits the array into halves, sorts each half, and merges them back together in sorted order.