Questions tagged [divide-and-conquer]

Divide-and-conquer is a top-down technique for designing algorithms that consists of dividing the problem into smaller subproblems hoping that the solutions of the subproblems are easier to find and then composing the partial solutions into the solution of the original problem.

The basic idea of divide-and-conquer technique is

1.Divide: Decompose problems into sub instances.
2.Conquer: Solve sub instances successively and independently.
3.Combine: Combine the sub solutions to obtain the solution to the original problem.

706 questions
-9
votes
2 answers

How can I make this python function run O(log n) time instead of O(n) time?

def findMax(f,c): n=1 while f(n) <= c: n += 1 return n This is a higher-order python function that given function f and a maximal count, c returns the largest n such that f(n) ≤ c. This works but not when n gets too large for e.g…
1 2 3
47
48