Professional Documents
Culture Documents
LEC5 05 خوارزميات أ زاهر مترجمة للطبع
LEC5 05 خوارزميات أ زاهر مترجمة للطبع
Conquer Approach
.1
.2
.3
AKRAM_LOQMAN_773133872 4
Three Steps of The Divide and
Conquer Approach
Problem of size n
Subproblem 1 Subproblem 2
of size n/2 of size n/2
Solution to Solution to
subproblem 1 subproblem 2
Solution to the
AKRAM_LOQMAN_773133872 original probelm 5
1 2
n/2 n/2
AKRAM_LOQMAN_773133872 6
Min And Max Example
Find the min and max of {3,5,6,2,4,9,3,1}.
A = {3,5,6,2} and B = {4,9,3,1}.
min(A) = 2, min(B) = 1.
max(A) = 6, max(B) = 9.
min{min(A),min(B)} = 1.
max{max(A), max(B)} = 9.
AKRAM_LOQMAN_773133872 31
{8,2,6,3,9,1,7,5,4,2,8}
{8,2,6,3,9} {1,7,5,4,2,8}
AKRAM_LOQMAN_773133872 33
{1,9}
{2,9} {1,8}
AKRAM_LOQMAN_773133872 34