KEMBAR78
Sequential and Parallel Searching Algorithms | PDF
Sequential and Parallel Searching
Algorithms
Presented By
Nishant Mahat 074MSCSK006
Rachana Kunwar 074MSCSK009
Suresh Mainali 074MSCSK014
Suresh Pokharel 074MSCSK015
(Msc. In Computer System and Knowledge Engineering, Pulchowk Campus )
Introduction
● Parallel search or multithreaded search is a way to increase search speed by
using additional processors.
● Parallel search algorithms are classified by their scalability (that means the
behavior of the algorithm as the number of processors become large) and their
speed up.
● The speed up is defined as the ratio of the running time of the sequential
execution to the running time of the parallel execution.
● Speed up acts as an indicator for a parallel program’s performance.
Sequential Search Algorithms
The search starts at the first record and
moves through each record until a match is
made, or not made.
Time complexity: O(n), ie. grows linearly as
the no. of items increases
int arraySize = arr.length;
for(int i = 0; i < arraySize; i++) {
if(arr[i] == key) {
return i;
}
}
return -1;
Sequential vs. Parallel Searching
Example: Sequential Bubble Sort
● Compares two consecutive values at a time and swaps them if they are out of
order.
● Greater values are being moved towards the end of the list.
● Number of comparisons and swaps:
which corresponds to a time complexity O(n2
)
Example: Sequential Bubble Sort
Sequential Parallel Search Algorithm
Input:- An unsorted array S and
the search element y
Output:- The position of y
The unsorted array is first decomposed into
n/p subarrays.
Complexity: O(log(n+1)/log(p+1))
for k = 0 to n-2
if k is even then
for i = 0 to (n/2)-1 do in parallel
If A[2i] > A[2i+1] then
Exchange A[2i] ↔ A[2i+1]
else
for i = 0 to (n/2)-2 do in parallel
If A[2i+1] > A[2i+2] then
Exchange A[2i+1] ↔ A[2i+2]
Example: Parallel Bubble Sort
The basic idea is to run multiple iterations in parallel.
Operates in two alternate phases:
Phase-even:
Even processes exchange values
with right neighbors.
Phase-odd:
Odd processes exchange values
with right neighbors.
References
● http://nptel.ac.in/courses/106106112/Module5/Lecture%202/Lecture%202.pdf
[Searching on a random sequence in parallel]
● https://researchgate.net/publication/267739792_High_Performance_Pattern_
Matching_on_Heterogeneous_Platform [High Performance Pattern Matching on
Heterogeneous Platform]

Sequential and Parallel Searching Algorithms

  • 1.
    Sequential and ParallelSearching Algorithms Presented By Nishant Mahat 074MSCSK006 Rachana Kunwar 074MSCSK009 Suresh Mainali 074MSCSK014 Suresh Pokharel 074MSCSK015 (Msc. In Computer System and Knowledge Engineering, Pulchowk Campus )
  • 2.
    Introduction ● Parallel searchor multithreaded search is a way to increase search speed by using additional processors. ● Parallel search algorithms are classified by their scalability (that means the behavior of the algorithm as the number of processors become large) and their speed up. ● The speed up is defined as the ratio of the running time of the sequential execution to the running time of the parallel execution. ● Speed up acts as an indicator for a parallel program’s performance.
  • 3.
    Sequential Search Algorithms Thesearch starts at the first record and moves through each record until a match is made, or not made. Time complexity: O(n), ie. grows linearly as the no. of items increases int arraySize = arr.length; for(int i = 0; i < arraySize; i++) { if(arr[i] == key) { return i; } } return -1;
  • 4.
  • 5.
    Example: Sequential BubbleSort ● Compares two consecutive values at a time and swaps them if they are out of order. ● Greater values are being moved towards the end of the list. ● Number of comparisons and swaps: which corresponds to a time complexity O(n2 )
  • 6.
  • 7.
    Sequential Parallel SearchAlgorithm Input:- An unsorted array S and the search element y Output:- The position of y The unsorted array is first decomposed into n/p subarrays. Complexity: O(log(n+1)/log(p+1)) for k = 0 to n-2 if k is even then for i = 0 to (n/2)-1 do in parallel If A[2i] > A[2i+1] then Exchange A[2i] ↔ A[2i+1] else for i = 0 to (n/2)-2 do in parallel If A[2i+1] > A[2i+2] then Exchange A[2i+1] ↔ A[2i+2]
  • 8.
    Example: Parallel BubbleSort The basic idea is to run multiple iterations in parallel. Operates in two alternate phases: Phase-even: Even processes exchange values with right neighbors. Phase-odd: Odd processes exchange values with right neighbors.
  • 9.
    References ● http://nptel.ac.in/courses/106106112/Module5/Lecture%202/Lecture%202.pdf [Searching ona random sequence in parallel] ● https://researchgate.net/publication/267739792_High_Performance_Pattern_ Matching_on_Heterogeneous_Platform [High Performance Pattern Matching on Heterogeneous Platform]