Divide and Conquer

The main idea of divide and conquer is to split the main problem into two smaller components, assuming that each one of the components had already been solved recursively, and then try to solve the bigger problem using the solutions of the two smaller components. For example, merge sort is a perfect case of a divide and conquer problem.

In merge sort, we first divide the array given into two components, the first half and the second half. After dividing them into these two components, we then recursively apply merge sort algorithm on each of these components and assume that they are already sorted. Now the problem becomes merging two sorted arrays into one sorted array. We can use a pointer on each of these sorted arrays to solve the last part of the problem.



Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Contrary to popular belief, Lorem Ipsum is not simply random text.

1  >>> a = [1, 2, 3]
2  >>> a[-1]
3  3

Get premium for instant access to all content and solutions