Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Parallel and distributed algorithm
1. Parallel Algorithms
Preorder Tree Traversal- The problem of preorder tree traversal may
look like sequential when viewed in terms of node traversal because to
assign labels to right sub tree we have to assign labels to left sub tree or
like that. But when viewed in terms of edges traversal the tree traversal
is viewed as traversal of linked list first when going towards downward
and another when going towards upwards. And linked list is processed
as parallel algorithm, which has four steps:
1. Construct singly linked list where nodes corresponds to upward or
downward edges of tree.
2. Assign weights to the node of the singly linked list. Assign weight
one to downward edge or zero to upwards edge.
3. Compute the rank of each element in the singly linked list.
4. Downward edges processors use the ranks to assign a preorder
traversal number to their associated nodes.
Data Structure- Every tree node has
Parent
Sibling (Right)
Child (leftmost )
The algorithm uses 2(n-1) processors for parallel computation, (n-1) for
downward edges and (n-1) for upward edges. All processors construct a
linked list corresponds to edges in the preorder traversal. They decide
which is next successor edge in traversal.
2. After construction of linked list, they assign position value to all nodes,
one for downward edges or 0 for upward edges. After that the pointer
jumping algorithm assigns final position to them.
Merging Two Sorted Lists
Merging of two sorted list algorithm can be performed in low time
using parallel algorithm. Optimal sequential algorithm can merge two
sorted list of n/2 elements in
time. And one parallel algorithm
using n processor can perform the task in
time by assigning
every element to its own processor.
Every Processor finds the position of its element using binary search.
And all n elements can be inserted into the merged list in constant
time.
First all processors are activated than they determine the range of
indices they are going to search. The processors associated with
elements in the upper half of the array will perform binary search on
elements in the lower half of the array and lower half elements
perform binary search on upper half elements of array.
The total operations have increased in parallel algorithm, by
to merge the lists.
to
Graph Coloring
We can assign a processor for every possible coloring of the graph, then
have each processor check to see if coloring is valid or not.
Let graph has n vertices, adjacencymatrix n x n and a constant c, a
processor is created for every possible coloring of the graph. Each
processor spends
time to determine if two adjacent vertices
3. have same color or not, if for any two adjacent vertices same color the
coloring is not valid.
Cost optimal parallel algorithmis an algorithm for which cost is in same
complexity as an optimal sequential algorithm.
Brent’s Theorem
According to Brent’s theorem “Given A, a parallel algorithm with
computation time t, if parallel algorithm A perform m computational
operations, then p processors can execute algorithm A in time
t+(m-1)/p”
According to Brent’s theorem to reduce the cost of parallel algorithm,
we must reduce the number of processors and use processors in
efficient manner.