ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Parallel & Distributed Computing
    COMP3139
    Progress0 / 33 topics
    Topics
    1. Introduction to Parallel and Distributed Systems2. Why Use Parallel and Distributed Systems?3. Speedup and Amdahl's Law4. Hardware Architectures: Multi Processors (Shared Memory)5. Hardware Architectures: Networks of Workstations (Distributed Memory)6. Hardware Architectures: Clusters (Latest Variation)7. Software Architectures: Threads and Shared Memory8. Software Architectures: Processes and Message Passing9. Software Architectures: Distributed Shared Memory (DSM)10. Software Architectures: Distributed Shared Data (DSD)11. Parallel Algorithms12. Concurrency and Synchronization13. Data and Work Partitioning14. Common Parallelization Strategies15. Granularity16. Load Balancing17. Examples of Parallel Algorithms: Parallel Search18. Examples of Parallel Algorithms: Parallel Sorting19. Shared-Memory Programming20. Threads in Shared-Memory Programming21. P Threads22. Locks and Semaphores23. Distributed-Memory Programming24. Message Passing25. Map Reduce26. Distributed-Memory Programming with PI27. Google's Map Reduce28. Hadoop29. Other Parallel Programming Systems30. Tread Marks31. Distributed Shared Memory32. Aurora: Scoped Behavior and Abstract Data Types33. S Enterprise: Process Templates
    COMP3139›Examples of Parallel Algorithms: Parallel Search
    Parallel & Distributed ComputingTopic 17 of 33

    Examples of Parallel Algorithms: Parallel Search

    9 minread
    1,564words
    Intermediatelevel

    Parallel Algorithms: Parallel Search

    A parallel search algorithm is a type of algorithm designed to improve the efficiency of searching operations by utilizing multiple processors or cores to search for an element or pattern in a dataset simultaneously, rather than sequentially. Parallel search can significantly reduce the time complexity of search operations in large datasets or complex problem spaces.

    In a sequential search, the algorithm typically examines one element at a time. In a parallel search, the dataset is divided into smaller sections, and each processor searches its assigned section independently, potentially speeding up the process dramatically. Parallel search is particularly useful in scenarios where the search space is large and the work can be divided into independent tasks.

    Let’s dive into a few key types of parallel search algorithms and their examples.


    1. Parallel Linear Search

    In parallel linear search, the goal is to find a particular element in an unsorted list or array. Instead of checking each element sequentially, the search space is divided into multiple segments, and each processor searches a portion of the array in parallel.

    How it works:

    • The list is divided into subarrays, and each processor is responsible for searching one subarray.
    • Once a processor finds the element, it can communicate this result back to the central processor or coordinator.
    • If no processor finds the element, the search continues until all subarrays have been checked.

    Example:

    Consider a list of size 10,000 with 4 processors:

    1. Divide the list: Split the list into 4 subarrays of 2,500 elements each.
    2. Parallel search: Each processor independently searches through its subarray.
    3. Result: Once one of the processors finds the element, the search terminates, and the result is returned.

    Complexity:

    • Time Complexity: The sequential search has a time complexity of O(nO(nO(n). In the parallel version, with ppp processors, each searching a subarray of size n/pn/pn/p, the time complexity can be reduced to approximately O(n/pO(n/pO(n/p), where nnn is the size of the dataset and ppp is the number of processors.
    • Ideal Speedup: In the best-case scenario, the search will be ppp-times faster than the sequential version, though overheads such as communication and synchronization may reduce the effective speedup.

    2. Parallel Binary Search

    Parallel binary search works on sorted arrays or lists and attempts to divide the search space based on the binary search algorithm, where the array is repeatedly divided in half. This approach is more efficient for sorted datasets compared to linear search.

    How it works:

    • The array is divided into two halves, and multiple processors search in parallel in the two halves. Each processor is responsible for checking if the target element lies in the left or right half.
    • After the first level of division, the process can continue recursively, with each processor splitting its segment of the array further.

    However, one key challenge is that binary search requires a sequential decision-making process: after checking the middle element, the next step depends on whether the element is larger or smaller. So, while the divide step can be parallelized, the actual decision-making must be done carefully to avoid race conditions or conflicts.

    Example:

    Consider a sorted array of size 1,000,000:

    1. Divide the array: Split the array into two halves and assign each half to a different processor.
    2. Search in parallel: Each processor performs a binary search on its half of the array.
    3. Recursive division: The halves are further split, and processors continue the binary search until the element is found or determined to be absent.

    Complexity:

    • Sequential Complexity: The time complexity of a standard binary search is OOOlog n$$).
    • Parallel Complexity: Although the search space is divided at each level, the total time complexity will still be dominated by the logarithmic depth of the search, which is OOOlog n$$), because the decision-making process (whether to search the left or right half) still requires synchronization. However, parallelism can help speed up the search by processing the search on multiple levels simultaneously.

    Parallel binary search is particularly useful when searching in very large datasets or distributed databases where the elements are stored across different processors or nodes.


    3. Parallel Search in Trees (Parallel Tree Search)

    Tree search is a common problem in parallel computing, especially in decision trees, game trees, or large-scale database indexing. A parallel tree search involves exploring nodes of a tree structure in parallel to find a particular element or solution.

    How it works:

    • A tree is divided into subtrees, and each processor is responsible for searching its assigned subtree.
    • In depth-first search (DFS) or breadth-first search (BFS) algorithms, the tree is explored recursively or iteratively, respectively.
    • In parallel DFS, processors explore different branches of the tree, potentially reducing the depth of the search.
    • In parallel BFS, multiple levels of the tree can be explored simultaneously, which is especially useful in scenarios like graph traversal or AI game search (e.g., searching for moves in a game tree like chess).

    Example:

    In a binary tree with 1,000 nodes:

    1. Divide the tree: The tree is split into subtrees (e.g., left and right subtrees).
    2. Parallel search: Each processor searches a subtree independently.
    3. Result: If a processor finds the element in its subtree, it terminates the search, and the result is propagated back.

    Complexity:

    • Sequential Complexity: For a balanced tree, the depth is OOOlog n),andasequentialDFSorBFShasatimecomplexityof), and a sequential DFS or BFS has a time complexity of ),andasequentialDFSorBFShasatimecomplexityofO(n)where) where )wheren$$ is the number of nodes.
    • Parallel Complexity: In the parallel version, assuming ppp processors are used, the work is divided into ppp subtrees. In ideal conditions, the time complexity could be reduced to O(n/pO(n/pO(n/p), but synchronization and communication overheads will reduce the effective performance.

    Parallel tree search is commonly used in AI applications, game engines (like for searching game states), and large-scale database indexing (e.g., searching in B-trees or other balanced trees).


    4. Parallel Pattern Matching

    Pattern matching is used to find a specific sequence of characters or elements in a larger dataset (e.g., finding a substring in a string). In parallel pattern matching, multiple processors can work in parallel to find all occurrences of the pattern.

    How it works:

    • The search string or text is divided into substrings, and each processor searches for the pattern in its assigned substring.
    • In multi-pattern matching, processors can also search for multiple patterns in parallel.
    • Once a processor finds a match, it can report the result, or the results are gathered by a central processor.

    Example:

    Consider searching for a pattern "abc" in a large text of size 1,000,000 characters using 4 processors:

    1. Divide the text: The text is split into 4 parts, each part being 250,000 characters long.
    2. Parallel search: Each processor searches for the pattern "abc" in its part of the text.
    3. Report results: Once the pattern is found, the results (the indices where the pattern was found) are communicated back.

    Complexity:

    • Sequential Complexity: A naive sequential search for a pattern in a text of length nnn takes O(nO(nO(n).
    • Parallel Complexity: In a parallel setting with ppp processors, the search complexity can be reduced to O(n/pO(n/pO(n/p), assuming perfect load balancing and no significant overhead.

    Parallel pattern matching is used in text search engines, bioinformatics (e.g., searching for DNA sequences), and in algorithms like Aho-Corasick for multi-pattern matching.


    Conclusion

    Parallel search algorithms are essential for speeding up search operations, especially in large-scale datasets or when high performance is needed. The main approaches—parallel linear search, parallel binary search, parallel tree search, and parallel pattern matching—demonstrate how parallelism can be leveraged to reduce search time. The effectiveness of these algorithms depends on factors such as the nature of the data, the architecture of the system, and the specific search problem being addressed.

    • Linear Search: Useful for unsorted data and can be easily parallelized.
    • Binary Search: More efficient for sorted data, though parallelization is limited by the need for sequential decision-making.
    • Tree Search: Common in AI and game algorithms, with parallelism useful for searching large or complex decision trees.
    • Pattern Matching: Efficient in scenarios requiring text search or multi-pattern matching, with significant benefits from parallelism in large datasets.

    The parallelization of search algorithms helps reduce the computational complexity and makes systems more scalable, especially in the age of big data and distributed computing.

    Previous topic 16
    Load Balancing
    Next topic 18
    Examples of Parallel Algorithms: Parallel Sorting

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time9 min
      Word count1,564
      Code examples0
      DifficultyIntermediate