0% found this document useful (0 votes)
3 views

Module 2 Slides II

This document covers Module 2 of a course on Algorithms and Complexity Analysis, focusing on Divide-and-Conquer techniques. Key topics include the multiplication of large integers using Karatsuba's method, Strassen’s matrix multiplication, and the closest pair problem. The document outlines the steps and efficiency of these algorithms as well as their applications in solving complex problems.

Uploaded by

FG na Terrorists
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Module 2 Slides II

This document covers Module 2 of a course on Algorithms and Complexity Analysis, focusing on Divide-and-Conquer techniques. Key topics include the multiplication of large integers using Karatsuba's method, Strassen’s matrix multiplication, and the closest pair problem. The document outlines the steps and efficiency of these algorithms as well as their applications in solving complex problems.

Uploaded by

FG na Terrorists
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

COSC 401

ALGORITHMS
AND
COMPLEXITY ANALYSIS

MODULE 2
LECTURE SLIDES II
MODULES
• MODULE 1: FUNDAMENTALS OF THE ANALYSIS AND DESIGN OF
ALGORITHM
• Study Session 1: Introduction to Algorithmic Problem Solving Study
• Session 2: Asymptotic Notations and Analysis of Algorithms Study
• Session 3: Brute-Force Selection Sort, String Matching, Closest-Pair & Exhaustive Search
Problems
• Study Session 4: Decrease and Conquer Technique
• MODULE 2: DIVIDE-AND-CONQUER, TRANSFORM-AND CONQUER
& SPACE-TIME-TRADE-OFFS
• Study Session 1: Divide and Conquer- Mergesort, Quicksort & Binary Search
• Study Session 2: Multiplication of Large Integers, Stassen’s Matrix Multiplication & Closest
Pair Problem
• Study Session 3: Transform & Conquer: Instance Simplification, Representational Change and
• Problem Reduction
• Study Session 4: Space-Time Trade-Offs String Matching & Hashing Algorithms
• MODULE 3: DYNAMIC PROGRAMMING& GREEDY TECHNIQUES
• Study Session 1: Dynamic Programming
• Study Session 2: Greedy Technique
• Study Session 3: Limitation of Algorithmic Powers
Study Session Learning Outcomes

• After studying this session, I expect you to be able to:


• Understand the Multiplication of Large Integers.

• Understand the Strassen’s Matrix Multiplication

• Understand the Closest Pair Problem


Divide and Conquer Algorithm Design
Technique
• As discussed in the previous session
• The Divide and Conquer algorithm solves a problem using following
three steps.
• Divide: Break the given problem into sub problems of same type.

• Conquer: Recursively solve these sub problems.

• Combine: Appropriately combine the answers.


Multiplication of Large Integers
• The divide-and-conquer approach provides a fast way of multiplying
large integers.
• The introduction of the technique is attributed to a Russian
mathematician Anatoly Karatsuba, and indeed, it is sometimes called
Karatsuba multiplication.
• With divide-and-conquer multiplication, we split each of the numbers
into two halves, each with n/2 digits.
• Assuming the two numbers we're trying to multiply a and b, with the
two halves of a being aL (the left or upper half) and aR (the right or
lower half) and
• The two halves of b being bL and bR. Basically, we can multiply these
two numbers as follows.
• Thus, in order to multiply a pair of n-digit numbers, we can recursively
multiply four pairs of n/2-digit numbers.
• To enhance the efficiency of this technique, we can reduce the
number of n/2-digit multiplications from four to three.
• What we'll do is compute the following three products using the
recursive calls:
Example
• Consider the multiplication 23× 14.
Stassen’s Matrix Multiplication
• Divide and conquer technique is used in the Stassen’s matrix multiplication
which outperforms the convection matrix multiplication in terms of time
efficiency.
• The principal insight of the algorithm lies in the discovery that we can find
the product C of two 2 × 2 matrices A and B with just seven multiplications as
opposed to the eight required by the brute-force (convectional) algorithm.
• So, given any 2 ×2 matrices, the Strassen’s multiplication uses the following
formula:
Steps are required to perform Strassen’s
Multiplication
• Step 1: Divide a matrix of order n× 𝑛 recursively till matrices of 2× 2
order are obtained.
• Step 2: Use the previous set of formulas to carry out 2× 2 matrix
multiplication.
• Step 3: Combine the results to get the final product matrix.
Closest Pair Problem
• We now present the divide and conquer approach to solving the closest
pair problem.
• To address the closest pair problem, the divide and conquer approach
takes the following steps:
• Let P be a set of n >1 points in the Cartesian plane, if 2 ≤ n ≤ 3, the problem
can be solved by the obvious brute-force algorithm.
• If n > 3, we can divide the points into two subsets Pl and Pr of ⌈n/2 ⌉ and ⌊n/2⌋
points, respectively, by drawing a vertical line through the median m of their x
coordinates so that ⌈n/2 ⌉points lie to the left of or on the line itself, and ⌊n/2⌋
points lie to the right of or on the line.
• Then we solve the closest-pair problem recursively for subsets Pl and Pr . Let
dl and dr be the smallest distances between pairs of points in Pl and Pr,
respectively, and let d = min{ dl , dr}.
• Note that d is not necessarily the smallest distance between all the
point pairs because points of a closer pair can lie on the opposite sides
of the separating line.
• We limit our attention to the points in the symmetric vertical strip of
width 2d as possible closest pair.
• Let C1 and C2 be the subsets of points in the left subset Pl and of the
right subset Pr, respectively, that lie in this vertical strip.
• The points in C1 and C2 are stored in increasing order of their y
coordinates, which is maintained by merging during the execution of
the next step.
• For every point P(x, y) in C1, we inspect points in C2 that may be
closer to P than d. There can be no more than 6 such points.
Conclusion

• In this session, we discussed the divide and conquer algorithm design


technique. Problems such as the multiplication of large integers,
strassen’s matrix multiplication and the closest pair problem where
solved using the algorithm design technique. Algorithms for these
problems and their analysis was also studied. In our next session, we
will be studying the transform and conquer algorithm design technique

You might also like