AlgorithmStrategies

# AlgorithmStrategies - Divide and Conquer Algorithm In...

• Notes
• morouj1
• 7

This preview shows pages 1–7. Sign up to view the full content.

Divide and Conquer Algorithm In computer science, divide and conquer (D&C) is an important algorithm design based on multi-branched recursion. A divide and conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same (or related) type, until these become simple enough to be solved directly. The solutions to the sub-problems are then combined to give a solution to the original problem. The name "divide and conquer" is sometimes applied also to algorithms that reduce each problem to only one sub problem, such as the binary search algorithm for finding a record in a sorted list

This preview has intentionally blurred sections. Sign up to view the full version.

Divide and Conquer Algorithm Divide-and conquer is a general algorithm design: Divide: divide the input data S in two or more disjoint subsets S 1 , S 2 , … Recur: solve the sub problems recursively. Conquer: combine the solutions for S 1 , S 2 , …, into a solution for S. The base case for the recursion are sub problems of constant size. Analysis can be done using recurrence equations.
Binary Search Algorithm

This preview has intentionally blurred sections. Sign up to view the full version.

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Can only be performed on a sorted list !!! Uses divide and conquer technique to search list Binary Search Algorithm (Cont’d) Search item is compared with middle element of list. If search item < middle element of list, search is restricted to Frst half of the list. If search item > middle element of list, search second half of the list. If search item = middle element, search is complete. Binary Search Algorithm (Cont’d) Determine whether 75 is in the list. Figure 1: Array list with twelve (12) elements Figure 2: Search list, list[0] … list[11] Binary Search Algorithm (Cont’d) Figure 3: Search list, list[6] … list[11] Advantages and Disadvantages Advantages: Solving difcult problem -> Example Towers oF Hanoi. Algorithm Efciency –> O(n log n) Parallelism -> Shared memory concept Memory access -> Efcient use oF memory caches. Disadvantages: Recursion is slow More complicated approach....
View Full Document

• Summer '14
• blal
• Computer Science, Divide and conquer algorithm, Hanoi, Binary search algorithm

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern