ITA - Week 5 Flashcards
1
Q
Divide and Conquer
A
A problem is divided into several subproblems
The subproblems are solved (typically recursively)
The subproblems are combined
2
Q
Known divide and conquer algorithms
A
Binary search
Mergesort
3
Q
What is Mergesort
A
The problem is divided into 2, both halves are solved and later recombined
4
Q
Merge subroutine
A
Get 2 pointers, check the smaller number and add to final list while increasing pointer by 1.
5
Q
Divide and conquer x^8
A
x^8 = (((x^2)^2)^2)
6
Q
Divide and conquer x^2r
A
((x^2)^2) - r times
7
Q
Algorithm for exponention
A
If exponent (n) is odd multiply result by x and decrease n by 1 If exponent (n) is even square current value of x and divide n by 2 Repeat until n = 0