0% found this document useful (0 votes)
27 views14 pages

Distributed Dbase

Distributed network in Computing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views14 pages

Distributed Dbase

Distributed network in Computing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Abubakar Tafawa Balewa University, Bauchi

Faculty of Science
Department of Mathematical Sciences
M.Sc. Computer Science

CS605: Algorithmic theory and Applications


Assignment / presentation

On
DESIGN STRATEGIES ON ALGORITHMS

By
GROUP B
Amos Joseph Onuh PGS/18-19/1/M/9003
Nabage Salih Abdullah PGS/18-19/1/M/
Emmanuel Datti PGS/18-19/1/M/
Aliyu Mahammuda Wushishi PGS/18-19/1/M/
Kennedy PGS/18-19/1/M/
INTRODUCTION

An algorithm is a sequence of unambiguous instructions


for solving a problem, i.e., for obtaining a required output
for any legitimate input in a finite amount of time.

Algorithm design strategies are techniques used to


modify algorithm executions and performance.
ALGORITHM DESIGN STRATEGIES
Control abstraction.

Binary search.

Quick sort.

Stressen matrix multiplication.


DIVIDE & CONQUER
 In this method, the given problem is divided into sub-problems till the sub-
problem is easily solvable
 The decision is continued until the sub-problems are solvable.
 Each sub-problem is solved using the same principle
 For every sub-problem there will be a single solution
 Hence, in Divide and Conquer (DAC) the size of the input is reduced so as to
reduce the size of a problem.

Decision
Sub-problem
continue
#1
s

Sub-problem Sub-problem
#2 BIG problem #4 Sub-problem solved
SP SP SP SP
1 2 3 3
Sub-problem
#3
DIVIDE & CONQUER

Divide and Conquer typical case


CONTROL ABSTRACTION

Control abstraction is the process by which


programmers define new control constructs,
specifying a statement ordering separately
from an implementation of that ordering
CONTROL ABSTRACTION OF DIVIDE
AND CONQUER
A control abstraction is a procedure whose flow of control is
clear but whose primary operations are specified by other
procedures whose precise meanings are left undefined.
Algorithm :

DandC(p)
{
if small (p) then return S(p);
else
{
Divide P into small instances P1, P2, P3……..Pk, k≥1;
Apply DandC to each of these sub-problems;\
return combine (DandC(P1), DandC(P1),…. (DandC(Pk);
}
}
BINARY SEARCH
In Binary Search, a sorted array by repeatedly
dividing the search interval in half. Begin with
an interval covering the whole array. If the
value of the search key is less than the item in
the middle of the interval, narrow the interval
to the lower half. Otherwise narrow it to the
upper half. Repeatedly check until the value is
found or the interval is empty.
ILLUSTRATION OF BINARY SEARCH
External and Internal path length of
Binary search
A binary tree T with ‘n’ internal nodes, will have I(T) + 2n = E(T) external nodes.
A binary tree corresponding to binary search when n = 16 is

Then we have,
CN = 1 + Internal path length of tree
N
C'N = 1 + External path length of tree
N+1
QUICK SORT
Quick sort is the other important sorting algorithm that is based on the divide-
and conquer approach.

Divides its input elements according to their position in the


array.

quick sort divides them according to their


value.
Quick sort algorithm
Algorithm QUICKSORT(low, high)
/* sorts the elements a(low), . . . . . , a(high) which reside in the global array A(1 : n)
Into ascending order a (n + 1) is considered to be defined and must be greater than
all elements in a(1 : n); A(n + 1) = + ∞ */
{
if low < high then
{
j := PARTITION(a, low, high+1);
// J is the position of the partitioning element QUICKSORT(low, j – 1);
QUICKSORT(j + 1 , high);
}
}
Stassen's Matrix Multification
The Strassen’s method of matrix multiplication is a typical divide and conquer
algorithm. Meaning that; the divide-and-conquer approach can reduce the number
of one-digit multiplications in multiplying two integers.

Let A and B be two n × n matrices where n is a power of 2. (If n is not a power of 2,


matrices can be padded with rows and columns of zeros.) We can divide A, B, and
their product C into four n/2 × n/2 sub-matrices each as follows:

You might also like