-- Feb 17 In-Class Exercise Thread
Binary: O(n * l * log(L)
Sequential: O(n * L)
Galloping: O(n * l (log(L/l) + 1))
Term 1 = f
Term 2 = f, 2f, 4f, 8f
n = 2
----- Case 1 -----
Term 2 = f
Binary:
O(2 * f * log(f))
= O(2flog(f))
Sequential:
O(2f)
Galloping:
O(2 * f (log(f/f) + 1)
= O(2f+1)
= O(2f)
- If terms are close, then Galloping is same as Sequential and at least as good as Binary.
----- Case 2 -----
Term 2 = 2f
Binary:
O(2 * f * log(2f))
= O(2flog(2f))
= O(2f(log(f)+ log2))
= O(2f(log(f) + 1))
= O(2flog(f) + 2f)
Sequential:
O(2 * 2f)
= O(4f)
Galloping:
O(2 * f (log(2f/f) + 1))
= O(2f(log2 + 1))
= O(2f + 2f)
= O(4f)
- If terms are still close, then Galloping is same as Sequential and at least as good as Binary.
----- Case 3 -----
Term 2 = 4f
Binary:
O(2 * f * log(4f))
= O(2flog(4f))
= O(2f(log4 + log(f)))
= O(4f + 2flog(f))
Sequential:
O(2 * 4f)
= O(8f)
Galloping:
O(2 * f (log(4f/f) + 1))
= O(2f(log4 + 1))
= O(4f + 2f)
= O(6f)
- As terms get further apart, Galloping is better than Sequential and materially similar to Binary.
----- Case 4 -----
Term 2 = 8f
Binary:
O(2 * f * log(8f))
= O(2flog(8f))
= O(2f(log8 + log(f)))
= O(6f + 2flog(f))
Sequential:
O(2 * 8f)
= O(16f)
Galloping:
O(2 * f (log(8f/f) + 1))
= O(2f(log(8)+1))
= O(2f(3 + 1))
= O(8f)
- As terms get further apart, Galloping is better than Sequential and materially similar to Binary.
Binary: O(n * l * log(L)
Sequential: O(n * L)
Galloping: O(n * l (log(L/l) + 1))
Term 1 = f
Term 2 = f, 2f, 4f, 8f
n = 2
----- Case 1 -----
Term 2 = f
Binary:
O(2 * f * log(f))
= O(2flog(f))
Sequential:
O(2f)
Galloping:
O(2 * f (log(f/f) + 1)
= O(2f+1)
= O(2f)
- If terms are close, then Galloping is same as Sequential and at least as good as Binary.
----- Case 2 -----
Term 2 = 2f
Binary:
O(2 * f * log(2f))
= O(2flog(2f))
= O(2f(log(f)+ log2))
= O(2f(log(f) + 1))
= O(2flog(f) + 2f)
Sequential:
O(2 * 2f)
= O(4f)
Galloping:
O(2 * f (log(2f/f) + 1))
= O(2f(log2 + 1))
= O(2f + 2f)
= O(4f)
- If terms are still close, then Galloping is same as Sequential and at least as good as Binary.
----- Case 3 -----
Term 2 = 4f
Binary:
O(2 * f * log(4f))
= O(2flog(4f))
= O(2f(log4 + log(f)))
= O(4f + 2flog(f))
Sequential:
O(2 * 4f)
= O(8f)
Galloping:
O(2 * f (log(4f/f) + 1))
= O(2f(log4 + 1))
= O(4f + 2f)
= O(6f)
- As terms get further apart, Galloping is better than Sequential and materially similar to Binary.
----- Case 4 -----
Term 2 = 8f
Binary:
O(2 * f * log(8f))
= O(2flog(8f))
= O(2f(log8 + log(f)))
= O(6f + 2flog(f))
Sequential:
O(2 * 8f)
= O(16f)
Galloping:
O(2 * f (log(8f/f) + 1))
= O(2f(log(8)+1))
= O(2f(3 + 1))
= O(8f)
- As terms get further apart, Galloping is better than Sequential and materially similar to Binary.