Divide and conquer algorithm

The Divide and Conquer algorithm (also called the Divide and Conquer method) is a basis for many popular sorting algorithms. An algorithm is simply a series of

The Divide and Conquer algorithm (also called the Divide and Conquer method) is a basis for many popular sorting algorithms. An algorithm is simply a series of steps to solve a problem. The general idea of divide and conquer is to take a problem and break it apart into smaller problems that are easier to solve.

This idea can be seen in many popular algorithms. A helpful way to think of this idea, would be when a person looks through a dictionary. For example, if they are looking for the word “Dog”, and land on a page with the word “Firetruck”, the person knows that all the pages to the right of firetruck will not contain dog. They know this because D comes before F in the alphabet. This logic allows a person to spend less time searching, because every time they arrive on a page with the wrong letter, they know that they can ignore the pages to the right or left of that page. This is an example of dividing a problem up into smaller pieces. An algorithm that uses this idea is binary search. For example, to find an item in a sorted list, one would start by looking at the middle item. By comparing the item in the middle to the item one is looking for, one can tell which half of the list the item cannot be in. They only need to look in the other half. One would use this logic again on that half of the list, and so on until there is only one item they need to look at. This way they broke apart the problem of “where in the list is this item” into “which half of the list is this item in” and “where in that half of the list is this item.” Skipping half of the items each time lets them do much less work than looking at every item in the list.

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.