Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 602 Bytes

Lecture-03.md

File metadata and controls

30 lines (19 loc) · 602 Bytes

Divide and Conquer

  • Divide the problems into sub problems
  • Conquer sub problems recursively
  • Combine solutions

It is an algorithm design technique.

Examples

Merge sort

Binary search

  • Find x in sorted array
  • Only have one sub problem

X to the power of n

Fibonacci numbers

  • Bottom up algorithm: Compute F0, F1, …Fn O(n)
  • Recursive squaring
    • Matrix squaring O(lgn)

Exponential time is bad, Polynomial time is good

Matrix multiplication

  • Naive implementation: O(n^3), 8 times matrix multiplication
  • Strassen algorithm: O(n^2.81), 7 times matrix multiplication