Distributed Dbase
Distributed Dbase
Faculty of Science
Department of Mathematical Sciences
M.Sc. Computer Science
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
Binary search.
Quick sort.
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
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.