Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How would you Implement a multi-threaded linear search using c++ The parent process shall load a file of strings into an array (or a vector),

How would you Implement a multi-threaded linear search using c++

The parent process shall load a file of strings into an array (or a vector), split the array into n sections, and then create n number of threads. Each child thread shall search one of the n sections of the array, for the specified string. If the thread does find the string, it records a number of occurrences. The main threads, meanwhile, executes the threads join function. After all threads complete their search, then the main thread prints "string has been found by N threads, there are O occurrences for the sub-string where N is a number of threads that found the string and O is a number of times that sub-string is present in the selected string.

The program shall be ran using the following command line:

./multi-threaded <.txt file> <# of threads >

You may create your test file random.txt with random words.

The textfile example: opp, cdf, xyz, abc, xyz, opp, abc, xyz,xyz

Command line: words.txt, xyz, 4

The output example: The abc string has been found by 3 threads, there are 4 occurrences for the sub-string.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions