Documente Academic
Documente Profesional
Documente Cultură
For example,
For above example, your program should create 3 main folders “mid1”, “mid2” and “mid3”.
Use mkdir and execv system calls. Use man command if you don’t know how to use these system calls.
int main()
{
const int N = ...;
int a[N] = ...;
int key, i;
cout << "Enter a number: ";
cin >> key;
The program searches the array for a given number, and prints the index of the number in the array. If
the number is not found then the program shall output -1.
You are required to use two threads to speed up the search. The first thread shall search the first half of
the array, while the second shall examine the other half. If any thread found element other should
terminate immediately.
You need not to use any fancy algorithm for the search; rather you can use the simple linear search.
Assume no duplicates are there in the array. You can create only 1 Boolean global variable, and as many
static and dynamic variables.