C Program: (Knapsack Exhaustive): How do I add the 5 random generated values into the val [] arrays and how to add the total maximum weights ?
// returns maximum of two integers
int max(int a, int b) { return (a > b)? a : b;
}
// Returns the maximum value that can be put in a
knapsack of capacity W
int knapSackExhaustive(int W, int wt[], int val[], int
n){
if (n == 0 || W == 0)
return 0;
// If weight of the nth item is more than Knapsack capacity W,
then
// this item cannot be included
if (wt[n-1] > W)
return knapSackExhaustive(W, wt, val, n-1);
else return max( val[n-1] + knapSackExhaustive(W-wt[n-1], wt, val,
n-1),
knapSackExhaustive(W, wt, val, n-1)
);
}
int main() {
int i;
time_t t;
//Intializes random number generator
srand((unsigned) time(&t));
// Print 5 random values from 3 to 15
int q;
printf("Five Random Values:\n");
for( i = 0 ; i < 5 ; i++ ) {
int q=printf(" %d\n",rand() % 15+2);
}
int val[]= {i};
int j;
//Print 5 random weights from 1 and 10000
printf("Five Random Weights:\n");
for( j = 0 ; j < 5 ; j++ ) {
printf(" %d\n", rand() % 10000);
}
int wt[]={j};
int W = 10000;
int n = sizeof(val)/sizeof(val[0]);
n = sizeof(wt)/sizeof(wt[0]);
printf("Total Value: %d\t\n", knapSackExhaustive(W, wt, val,
n));
printf("Total Weight:\t");
return 0;
}
In: Computer Science
Discuss the influence of biological and genetic factors in deviance and crime and what role the health care community should play in controlling and modify anti-social and/or criminal behaviors. Use examples from your personal life and a quote or two from your textbook to support your ideas and cite them using the APA format.
In: Psychology
Suppose a company has proposed a new 4-year project. The project has an initial outlay of $70,000 and has expected cash flows of $20,000 in year 1, $23,000 in year 2, $29,000 in year 3, and $35,000 in year 4. The required rate of return is 12% for projects at this company. What is the discounted payback for this project? (Answer to the nearest tenth of a year, e.g. 3.2)
In: Finance
Optimus Company manufactures a variety of tools and industrial
equipment. The company operates through three divisions. Each
division is an investment center. Operating data for the Home
Division for the year ended December 31, 2020, and relevant budget
data are as follows.
Actual
Comparison with Budget
Sales$1,400,000$100,000 favorable
Variable cost of goods sold665,00045,000 unfavorable
Variable selling and administrative expenses125,00025,000 unfavorable
Controllable fixed cost of goods sold170,000On target
Controllable fixed selling and administrative expenses80,000On target
Average operating assets for the year for the Home Division were
$2,000,000 which was also the budgeted amount.
Prepare a responsibility report for the Home Division. (List
variable costs before fixed costs. Round ROI to 2 decimal places,
e.g. 1.57%.)
OPTIMUS COMPANY
Home Division
Responsibility Report
For the Year Ended December 31, 2020
Difference
Budget
Actual
Favorable
Unfavorable
Neither Favorable
nor Unfavorable
Gross ProfitControllable Direct Fixed CostsTotal Variable CostsVariable CostsContribution MarginControllable MarginTotal Controllable Direct Fixed CostsSalesCost of Goods SoldSelling and Administrative
$ $ $
FavorableUnfavorableNeither Favorable nor Unfavorable
SalesContribution MarginControllable Direct Fixed CostsSelling and AdministrativeControllable MarginCost of Goods SoldGross ProfitTotal Controllable Direct Fixed CostsTotal Variable CostsVariable Costs
Variable Costs Controllable Margin Contribution Margin Selling and Administrative Controllable Direct Fixed Costs Cost of Goods Sold Gross Profit Sales Total Controllable Direct Fixed Costs Total Variable Costs
FavorableUnfavorableNeither Favorable nor Unfavorable
Contribution Margin Total Controllable Direct Fixed Costs Controllable Direct Fixed Costs Selling and Administrative Total Variable Costs Variable Costs Controllable Margin Cost of Goods Sold Gross Profit Sales
FavorableUnfavorableNeither Favorable nor Unfavorable
Variable Costs Selling and Administrative Cost of Goods Sold Total Controllable Direct Fixed Costs Controllable Direct Fixed Costs Total Variable Costs Sales Contribution Margin Gross Profit Controllable Margin
FavorableUnfavorableNeither Favorable nor Unfavorable
SalesSelling and AdministrativeContribution MarginGross ProfitTotal Controllable Direct Fixed CostsVariable CostsTotal Variable CostsControllable Direct Fixed CostsControllable MarginCost of Goods Sold
FavorableUnfavorableNeither Favorable nor Unfavorable
Total Variable CostsControllable MarginVariable CostsContribution MarginCost of Goods SoldGross ProfitControllable Direct Fixed CostsTotal Controllable Direct Fixed CostsSalesSelling and Administrative
Contribution Margin Sales Selling and Administrative Variable Costs Cost of Goods Sold Total Controllable Direct Fixed Costs Controllable Direct Fixed Costs Controllable Margin Total Variable Costs Gross Profit
FavorableUnfavorableNeither Favorable nor Unfavorable
Controllable Margin Total Variable Costs Sales Total Controllable Direct Fixed Costs Cost of Goods Sold Variable Costs Contribution Margin Controllable Direct Fixed Costs Selling and Administrative Gross Profit
FavorableUnfavorableNeither Favorable nor Unfavorable
Total Controllable Direct Fixed Costs Controllable Margin Cost of Goods Sold Variable Costs Selling and Administrative Gross Profit Total Variable Costs Contribution Margin Controllable Direct Fixed Costs Sales
FavorableUnfavorableNeither Favorable nor Unfavorable
Controllable Direct Fixed CostsControllable MarginCost of Goods SoldGross ProfitSalesSelling and AdministrativeTotal Controllable Direct Fixed CostsTotal Variable CostsVariable CostsContribution Margin
$ $ $
FavorableUnfavorableNeither Favorable nor Unfavorable
ROI % % %
FavorableUnfavorableNeither Favorable nor Unfavorable
Compute the expected ROI in 2020 for the Home Division, assuming
the following independent changes to actual data. (Round ROI to 2
decimal places, e.g. 1.57%.)
The expected ROI
(1)Variable cost of goods sold is decreased by 5%. %
(2)Average operating assets are decreased by 10%. %
(3)Sales are increased by $200,000, and this increase is expected to increase contribution margin by $80,000. %
In: Accounting
In: Finance
Suppose that you select a sample of size 20 from a single state and find the mean is 31 (Xbar).
a. What is the upper value for the 95% confidence interval for the population mean (mu) for that state. (Assume the standard deviation (sigma) is the same as it is for the entire country (9.25)
b. What is the lower value for the abouve 95% confidence interval for the population mean (mu) for that state is.
In: Math
What are the four stages of investment in this alphabet soup, and what do they represent?
In: Finance
Given that business is about maximizing stakeholder wealth and given that there are laws governing the process by which this is accomplished, is there even room for ethics in business? In other words, if organizations (and organizational members) follow the law, is there any additional need for ethical considerations? When organizations maximize stakeholder wealth, aren't they already doing the "right" thing according to the design and purpose of organizational existence?
In: Finance
For each audit activity, identify the audit procedure. Each activity has one answer, but the audit procedures can be used more than once.
__ Review lease agreements for capital leases.
__ Select a sample of inventory items from the receiving reports and follow the items to inventory records.
__ Select a sample of fixed asset additions and ask to see the assets.
__ Review the client's calculation of the allowance for doubtful accounts.
__ Compare sales invoice quantities to shipment documentation quantities to verify the client's assertion that this procedure is done by client personnel.
__ Select a sample of entries in the payroll journal and match the employee name, date of payment, and amount of pay to the employee personnel file.
__ Ask production and sales personnel concerning possible obsolete or slow-moving inventory.
__ Watch that an independent person double-checks the payroll wage rates and calculations before checks are printed.
__ Calculate the percentage of sales for salary and wages expense for this year and the prior year for reasonable presentation.
__ Send a form to the bank for the balances of the payroll checking accounts.
Answer Bank
A. |
Vouching |
B. |
Tracing |
C. |
Scanning |
D. |
Observation |
E. |
Confirmation |
F. |
Inspection of assets |
G. |
Inquiry |
H. |
Analytical Procedures |
I. |
Recalculation |
J. |
Reperformance |
In: Accounting
Explain the most common reasons why people may be having problems sleeping? And provide at least three concrete non-pharmaceutical suggestions to improve the quality of sleep.
In: Psychology
2. Why do some countries refuse to join (or are leaving/left - Britain) the EU while others take advantage of the opportunity?
In: Operations Management
A converging-diverging rocket nozzle is connected to a combustion chamber filled with gas at a total pressure of 1200 kPa and a total temperature of 2400 K. The design exit Mach number is 2.9 and the nozzle throat area is 50 cm2 . Assume the gas behaves as an ideal gas with k = 1.3 and a molecular weight of 24 kg/kmol. Determine (a) The back pressure necessary to induce the design Mach number at the nozzle exit. (b) The design exit area for isentropic supersonic flow. (c) The static pressure at the throat when the flow is choked. (d) The mass flow rate through the nozzle when the flow is choked.
In: Mechanical Engineering
A farmer has been in the habit of always planting potatoes on his farm. In previous years, the seeds for the potatoes were planted in the spring, and were ready to harvest in mid-July. After that, a second planting took place in late July, which was ready to harvest in early October.
This year, however, there is concern that a blight might destroy some or all of the potato crop. One thing he could do would be to plant a different crop such as peas which would not be affected by the blight. The peas would have only a single planting at a cost of $40,000. This planting would yield a crop in October worth $70,000 if the weather turns out to be good, or $30,000 if the weather turns out to be poor. There is a 60% chance that the weather will be good.
If, however, he decides to plant potatoes, he will have to worry about the blight (but the weather has little effect on the potato crop and can be ignored). The potato crop would cost $60,000 to plant. There is a 10% chance of a severe blight, which would destroy the crop, and render any attempt at a second planting in late July not worth doing. A mild blight (20% chance) would partially destroy the crop, making it worth only $35,000, while having no blight (70% chance) would produce a crop worth $80,000. After either a mild blight or no blight, a second planting could be undertaken, with the same costs and revenues as the first. The probability of a severe, mild, or no blight would be 15%, 30%, and 55% if the first planting had a mild blight, but would be 0%, 5%, and 95% if the first planting had no blight.
NOTE: The crop planted in the Spring will be either peas or potatoes; doing a bit of both is not an option in this problem.
Draw the tree, solve it using the rollback procedure, and state the recommen- dation and the ranking payoff. When drawing the tree, use payoff nodes for inter- mediate payoffs.
Please show all workings and show where the numbers come from.
In: Operations Management
In: Finance
which is the stronger acid m nitrobenzoic acid or p nitrobenzoic acid? provide structures to support your choice?
In: Chemistry