4 Pram Algorithms
4 Pram Algorithms
PRAM Algorithms
Session
Session- -44
AIM OF THE SESSION
INSTRUCTIONAL OBJECTIVES
LEARNING OUTCOMES
Introduction:
•So far we have discussed algorithms for single processor
•In this session, we introduce parallel machines
•Example: weather forecasting
•If you start today to forecast tomorrow's weather using single
processor you may get result after few days (since its a Compute-
intensive problem)
PRAM Model
• So we need multiple machines/processors to solve such type of
problems.
• Parallel machines offer the potential of decreasing the solution time
enormously.
• The idea of parallel computing is very similar.
• Given a problem to solve, we partition the problem into many
subproblems; let each processor work on a subproblem; and when all the
processors are done, the partial solutions are combined to arrive at the
final answer.
• Any algorithm designed for a single-processor machine as a sequential
algorithm
• Any designed for a multiprocessor machine as a parallel algorithm.
Merging
Step 1: Partition X1 nad X2 into their odd and even parts. That is,
partition X1 into X1odd = k1,k3….km-1 and X1even = k2,k4,….km. Similarly,
partition X2 into X2odd and X2even.
Step 2: Recursively merge X1odd with X2odd using m processors. Let L1 = l1,l2,l3,
….lm be the result. Note that X1odd, X1even,X2odd, and X2even are in sorted order.
At the same time merge X1even with X2even using the other m processors to get L2
= lm+1, lm+2,…..l2m.
Step 3: Shuffle L1 and L2; that is form the sequence L = l1, lm+1,l2, lm+2, … lm,l2m.
Compare every pair (lm+i,li+1) interchange them if they are out of order. That is,
compare lm+1 with l2 and interchange them if need be, compare lm+2 with l3 and
interchange them if need be, and so on. Output the result sequence.
Example
A. Greedy
B. Divide and Conquer
C. Dynamic
D. Backtracking
TERMINAL QUESTIONS
Text Books :
1. Ellis Horowitz, Sartaj Sahni and Sanguthevar Rajasekaran, “Fundamentals of
ComputerAlgorithms”, 2nd Edition, University Press, 2008.
2. Cormen, Leizerson &Rivest, “Introduction toalgorithms”, 3rd Edition, Prentice-Hall, 2002.
3. Jon Kleinberg and Eva Tardos, “Algorithm Design”,Pearson Education, 2006.
Reference Books :
1. Robert Sedgewick and Kevin wayne , “Algorithms”, 4th edition, Addison WesleyProf.,(2011).
2. Anny Levitin, “Introduction to Design and Analysis of Algorithms”, 2rd Edition,
PersonEducation Press. (2007).
3. Michael T.Goodrich and Roberto Tamassia, Algorithm Design: Foundations,Analysis and
Internet Examples, Second Edition, Wiley-India, (2006).
4. Steven S. Skiena, “The AlgorithmDesign Manual”, Second Edition, Springer, (2008)
MOOCS :
1. https://www.coursera.org/specializations/algorithms?=
2.https://www.coursera.org/learn/dynamic-programming-greedy-algorithms#modules
THANK YOU