Question: write the code in c , dont chat gpt Perform a binary search on a 1 6 - element sorted array by passing half the
write the code in c dont chat gpt
Perform a binary search on a element sorted array by passing half the array
to a child process. The parent should define the array, print it and ask the user to
input a target value. The parent will compare the target value to the mid element, call
fork, and and the child will operate on half of the array. Similarly, the next child will
operate on of the array and so on The child process that finds the target value
should print its index in the terminal. If the target doesnt exist in the array, print
Each parent should wait for their child to finish before returning. pts
Input: Define a element array in the code. The array must be sorted.
Output: Output format should be as follows:
Array:
Enter a target value:
Target values index:
Rubrics:
The student should have implemented the following things:
File qc containing the main function.
Defined a sorted element array.
Asked user for target value.
A child should operate on half of the array of its parent at each fork level.
There will be at most, forking levels.
The correct index of the target value in the array is printed. If the target is not
in the array, is printed.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
