Using the template given in ParallelMergeSort.c write the functions to divide the original array into equal fractions given the number of threads and perform Parallel MergeSort pThreads. Your algorithm should work for 2 threads.
ParallelMergeSort.c
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#define SIZE 100
int array[SIZE];
void fillArrayWithRandomNumbers(int arr[SIZE]) {
for(int i = 0; i<SIZE; i++) array[i] = rand()%100;
}
void printArray(int arr[SIZE]) {
for(int i = 0; i<SIZE; i++) printf("%5d", arr[i]);
printf("\n");
}
typedef struct StartEndIndexes {
int start;
int end;
} StartEndIndexes;
// Runs mergesort on the array segment described in the
// argument. Spawns two threads to mergesort each half
// of the array segment, and then merges the results.
void* mergeSort(void* args) {
return NULL;
}
int main() {
srand(time(0));
StartEndIndexes sei;
sei.start = 0;
sei.end = SIZE - 1;
// 1. Fill array with random numbers.
fillArrayWithRandomNumbers(array);
// 2. Print the array.
printf("Unsorted array: ");
printArray(array);
// 3. Create a 2 threads for merge sort.
// 4. Wait for mergesort to finish.
// 5. Print the sorted array.
printf("Sorted array: ");
printArray(array);
}
Makefile
mergeSort: ParallelMergeSort.c
gcc -std=c99 -pthread -o ParallelMergeSort
ParallelMergeSort.c -I.
In: Computer Science
A European option giving the right to sell a stock at $100 sells for $5. Under what circumstance will the buyer of the option make a profit?
Select one:
a. When the stock price at maturity is less than $100
b. When the stock price at maturity is greater than $100
c. When the stock price anytime up to maturity is less than $95
d. When the stock price at maturity is less than $95
In: Finance
Python Knapsack Problem:
Acme Super Store is having a contest to give away shopping sprees to lucky families. If a family wins a shopping spree each person in the family can take any items in the store that he or she can carry out, however each person can only take one of each type of item. For example, one family member can take one television, one watch and one toaster, while another family member can take one television, one camera and one pair of shoes.
Each item has a price (in dollars) and a weight (in pounds) and each person in the family has a limit in the total weight they can carry. Two people cannot work together to carry an item. Your job is to help the families select items for each person to carry to maximize the total price of all items the family takes. Write an algorithm to determine the maximum total price of items for each family and the items that each family member should select.
***In python:***
Implement your algorithm by writing a program named “shopping.py”. The program should satisfy the specifications below.
Input: The input file named “shopping.txt” consists of T test cases
T (1 ≤ T ≤ 100) is given on the first line of the input file.
Each test case begins with a line containing a single integer number N that indicates the number of items (1 ≤ N ≤ 100) in that test case
Followed by N lines, each containing two integers: P and W. The first integer (1 ≤ P ≤ 5000) corresponds to the price of object and the second integer (1 ≤ W ≤ 100) corresponds to the weight of object.
The next line contains one integer (1 ≤ F ≤ 30) which is the number of people in that family.
The next F lines contains the maximum weight (1 ≤ M ≤ 200) that can be carried by the ith person in the family (1 ≤ i ≤ F).
Output: Written to a file named “results.txt”. For each test case your program should output the maximum total price of all goods that the family can carry out during their shopping spree and for each the family member, numbered 1 ≤ i ≤ F, list the item numbers 1 ≤ N ≤ 100 that they should select.
Sample Input:
2
3
72 17
44 23
31 24
1
26
6
64 26
85 22
52 4
99 18
39 13
54 9
4
23
20
20
36
Sample Output:
Test Case 1
Total Price 72
Member Items
1: 1
In: Computer Science
You are preparing an 81 year old woman for discharge following a stroke. her husband will be the caregiver. what teaching might you to provide to prepare him for the caregiver role
In: Nursing
(a) Patty Stacey deposits $2200 at the end of each of 5 years in an IRA. If she leaves the money that has accumulated in the IRA account for 25 additional years, how much is in her account at the end of the 30-year period? Assume an interest rate of 6%, compounded annually. (Round your answer to the nearest cent.) (b) Suppose that Patty's husband delays starting an IRA for the first 10 years he works but then makes $2200 deposits at the end of each of the next 15 years. If the interest rate is 6%, compounded annually, and if he leaves the money in his account for 5 additional years, how much will be in his account at the end of the 30-year period? (Round your answer to the nearest cent.)
In: Advanced Math
In: Economics
In the RAND study, two plans had full coverage for spending within the hospital, but one had a $150 deductible for ambulatory care. The plan with the ambulatory care deductible had a lower probability of hospital admission (0.115) per year than did the plan with full coverage for everything (0.128), even though both plans covered hospital care fully. (See Table 5.4) What does that tell you about the use of hospital and ambulatory care? Are they substitutes or complements. Explain what’s happening in words your mom might understand. Are there policy implications to this finding?
In: Economics
Question 1 The following data represent the cost of electricity (in Rand) during July 2019 for a random sample of 30 one-bedroom apartments in a large city:
96 171 202 178 147 197 130 149 167 191 135 129 158 166 150 95 187 144 139 175 123 111 116 202 157 128 82 102 112 95
(a) Construct a stem and leaf graph for the given data. (10)
(b) Construct a histogram for the given data. (10)
(c) Draw a table with the relative frequencies and cumulative frequencies (in percentages) for all class intervals. (10)
(d) Draw a cumulative frequency polygon for the data. (10) In (b), (c) and (d), use the following class intervals: 82 101 142 161 202 221 102 121 162 181 122 141 182 20
In: Statistics and Probability
1-Sukriti is a 35 year old Northern Indian woman, who has recently (6-12 months ago) immigrated with her husband and two children to the United States. She is from a more affluent family and speaks English fluently, although she dresses in a more traditional Indian way. She was recently referred to you because she is overweight and has pre-diabetes (high blood sugar). Her husband accompanies her to your visit.
What are some things you might assume about Sukriti based on this description? (re: family, education, religion, food preferences)
2-How would you greet Sukriti and her husband?
3-What are (likely) some of Sukriti’s traditional foods?
4-What are (likely) her typical cooking or meal patterns?
5-Sukriti reports that she consumes the following diet daily: roti in the morning, stuffed with potatoes and cheese with coffee and milk, samosas during the day, pickles, fried chickpeas, and a balanced meal for dinner. What are some suggestions you might make to help her improve her health?
In: Nursing
The U.S. Census Bureau collects data on the ages of married people. Suppose that eight married couples are randomly selected and have the ages given in the following table. Determine the 98% confidence interval for the true mean difference between the ages of married males and married females.
Let d=(age of husband)−(age of wife)d=(age of husband)−(age of wife). Assume that the ages are normally distributed for the populations of both husbands and wives in the U.S.
| Husband | 43 | 63 | 65 | 30 | 33 | 33 | 66 | 22 |
|---|---|---|---|---|---|---|---|---|
| Wife | 34 | 66 | 72 | 26 | 25 | 24 | 63 | 23 |
Step 1 of 4:
Find the mean of the paired differences, d‾d‾. Round your answer to one decimal place.
Step 2 of 4:
Find the critical value that should be used in constructing the confidence interval. Round your answer to three decimal places.
Step 3 of 4:
Find the standard deviation of the paired differences to be used in constructing the confidence interval. Round your answer to one decimal place.
Step 4 of 4:
Construct the 98% confidence interval. Round your answers to one decimal place.
In: Statistics and Probability