We often need to shuffle data in many applications. Consider a case of a game that plays cards for example or a system that does a draw for lottery. The purpose of this lab is to write functions that will help us shuffle elements of an array.
Create a function that takes an array of integers and its size as parameters and populates the array with the values: 0, 1, 2, ..., size-1, where size is the size of the array.
Create a function that takes an array of integers and two indices (integers) and swaps the two elements. For example if I pass the array and 3 and 7 then the array will swap the element at index 3 with the element at index 7.
Create a function that takes an array of integers and its size as parameters and shuffles the array. You can accomplish this by going through the elements and exchanging each one with a randomly selected element (hint: use the method you created in step 2.
Create a function that takes an array of integers, its size and a value as parameters and returns the index at which the value is stored. If the array doesn't contain the value then the function returns -1. For example if the array is 1 4 6 2 10 11 12 and the value is 11 then the function returns 5 because 11 is stored at index 5. If the value is 20 then the function returns -1 because 20 is not in the array.
Create a function that takes an array of integers and its size as parameters and prints the contents of the array.
In main write code to test your function. Namely, creates an array of 15 integers, populate it, print it, shuffle it, print it again and print the index of an element in the array and the index of an element not in array .
Here is sample output:
Elements before shuffle: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Elements after shuffle: 9 8 10 6 5 12 14 2 7 3 4 1 13 11 0 What value are you searching for? 7 Element 7 is stored at index 8 What value are you searching for? 30 Element 30 is stored at index -1
In: Computer Science
A production manager knows that 8.5% of components produced by a particular manufacturing process have some defect. Eight of these components, whose characteristics can be assumed to be independent of each other were examined. a. Write the distribution function in terms of ? and x. b. What is the probability that none of these components has a defect? c. What is the probability that two of the components have a defect? d. What is the probability that between two and seven components have a defect? e. What is the probability that at most three of the components have a defect? f. What is the probability that at least two of these components have a defect? g. What is the expected defective components and the coefficient of variation?
In: Statistics and Probability
A “friend” borrows your favorite compass and paints the entire needle red. You discover this when you are lost in a cave and have with you two flashlights, a few meters of wire, and (of course) your physics textbook. How might you discover which end of your compass needle is the north-seeking end?
In: Physics
***SHOW SPSS**
A researcher is interested to learn if there is a linear relationship between the hours in a week spent exercising and a person’s life satisfaction. The researchers collected the following data from a random sample, which included the number of hours spent exercising in a week and a ranking of life satisfaction from 1 to 10 ( 1 being the lowest and 10 the highest).
|
Participant |
Hours of Exercise |
Life Satisfaction |
|
1 |
3 |
1 |
|
2 |
14 |
2 |
|
3 |
14 |
4 |
|
4 |
14 |
4 |
|
5 |
3 |
10 |
|
6 |
5 |
5 |
|
7 |
10 |
3 |
|
8 |
11 |
4 |
|
9 |
8 |
8 |
|
10 |
7 |
4 |
|
11 |
6 |
9 |
|
12 |
11 |
5 |
|
13 |
6 |
4 |
|
14 |
11 |
10 |
|
15 |
8 |
4 |
|
16 |
15 |
7 |
|
17 |
8 |
4 |
|
18 |
8 |
5 |
|
19 |
10 |
4 |
|
20 |
5 |
4 |
|
Diet |
|||
|
Exercise |
<30% fat |
30% - 60% fat |
>60% fat |
|
<60 minutes |
4 |
3 |
2 |
|
4 |
1 |
2 |
|
|
2 |
2 |
2 |
|
|
4 |
2 |
2 |
|
|
3 |
3 |
1 |
|
|
60 minutes |
6 |
8 |
5 |
|
or more |
5 |
8 |
7 |
|
4 |
7 |
5 |
|
|
4 |
8 |
5 |
|
|
5 |
6 |
6 |
In: Statistics and Probability
What is Cramer's V for each of the following values for the chi-square test for independence? (Round your answers to two decimal places.)
(a) X2 = 7.95, n = 130, df smaller = 2 V =
(b) X2 = 4.14, n = 60, df smaller = 1 V =
(c) X2 = 12.66, n = 190, df smaller = 3 V =
In: Statistics and Probability
| Year | Good |
Price |
Quantity |
|---|---|---|---|
2014 |
Ice cream cones |
$2.50 |
1,000 |
Hot dogs |
$1.25 |
500 |
|
Surfboards |
$100.00 |
10 |
|
2015 |
Ice cream cones |
$3.50 |
800 |
Hot dogs |
$2.25 |
400 |
|
Surfboards |
$100.00 |
|
4. a. Calculate nominal GDP for 2014 and 2015.
b. Calculate the percentage change in GDP from 2014 to 2015, first using 2014 prices and then using 2015 prices.
c. Calculate the percentage change in real GDP from 2014 to 2015, using your answers from part (b).
d. What is the GDP deflator for 2015 if it equals 1.0 in 2014?
5 Given the information in the following table for three consecutive years in the U.S. economy, calculate the missing data.
Year |
Nominal GDP (in billions of U.S. dollars) |
Real GDP (in billions of 2005 dollars) |
GDP Deflator (2005=100) |
Inflation (percent change in GDP deflator) |
Real GDP per Capita (in 2005 dollars) |
Population (in millions) |
|---|---|---|---|---|---|---|
2005 |
12,623 |
100.0 |
3.3 |
297.4 |
||
2006 |
12,959 |
3.2 |
300.3 |
|||
2007 |
106.2 |
45,542 |
303.3 |
6. Look at two scenarios, details of which are provided below, for monthly inventories and sales for a company producing cereal. In both scenarios, the company’s sales are the same.
|
Scenario A |
||||
|---|---|---|---|---|
|
Month |
Start-of-the-Month Inventory Stock |
Production |
Sales |
Inventory Investment |
|
Jan. |
50 |
50 |
45 |
|
|
Feb. |
50 |
55 |
||
|
Mar. |
50 |
80 |
||
|
Apr. |
50 |
50 |
||
|
May |
50 |
40 |
||
| Scenario B | ||||
|---|---|---|---|---|
|
Month |
Start-of-the-Month Inventory Stock |
Production |
Sales |
Inventory Investment |
|
Jan. |
50 |
45 |
45 |
|
|
Feb. |
55 |
55 |
||
|
Mar. |
80 |
80 |
||
|
Apr. |
50 |
50 |
||
|
May |
40 |
40 |
||
a.Calculate the inventory investment during each month and the resulting stock of inventory at the beginning of the following month for both scenarios.
b.Does maintaining constant production lead to greater or lesser fluctuations in the stock of inventory? Explain.
In: Economics
(C programming) Use a one-dimensional array to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, print it only if it’s not a duplicate of a number already read. Provide for the “worst case” in which all 20 numbers are different. Use the smallest possible array to solve this problem.
Your solution must include a function called isUnique() that returns 1 (true) if the number input is unique and 0 (false) otherwise . The implementation of this function must follow AFTER the implementation of main () in your .c file.
Output should be look like:
TEST SET 1
1 unique number
===============
Enter # 1 : 9
The number enetered is not in the valid range of 10 to 100
Enter # 1 : 101
The number enetered is not in the valid range of 10 to 100
Enter # 1 : 10
The number: 10 is unique
Enter # 2 : 10
Enter # 3 : 10
Enter # 4 : 10
Enter # 5 : 10
Enter # 6 : 10
Enter # 7 : 10
Enter # 8 : 10
Enter # 9 : 10
Enter # 10 : 10
Enter # 11 : 10
Enter # 12 : 10
Enter # 13 : 10
Enter # 14 : 10
Enter # 15 : 10
Enter # 16 : 10
Enter # 17 : 10
Enter # 18 : 10
Enter # 19 : 10
Enter # 20 : 10
All of the unique numbers found are:
10
TEST SET 2
20 unique numbers
=================
Enter # 1 : 10
The number: 10 is unique
Enter # 2 : 20
The number: 20 is unique
Enter # 3 : 30
The number: 30 is unique
Enter # 4 : 9
The number enetered is not in the valid range of 10 to 100
Enter # 4 : 101
The number enetered is not in the valid range of 10 to 100
Enter # 4 : 40
The number: 40 is unique
Enter # 5 : 50
The number: 50 is unique
Enter # 6 : 60
The number: 60 is unique
Enter # 7 : 70
The number: 70 is unique
Enter # 8 : 80
The number: 80 is unique
Enter # 9 : 90
The number: 90 is unique
Enter # 10 : 100
The number: 100 is unique
Enter # 11 : 95
The number: 95 is unique
Enter # 12 : 85
The number: 85 is unique
Enter # 13 : 75
The number: 75 is unique
Enter # 14 : 65
The number: 65 is unique
Enter # 15 : 55
The number: 55 is unique
Enter # 16 : 45
The number: 45 is unique
Enter # 17 : 35
The number: 35 is unique
Enter # 18 : 25
The number: 25 is unique
Enter # 19 : 15
The number: 15 is unique
Enter # 20 : 11
The number: 11 is unique
All of the unique numbers found are:
10 20 30 40 50
60 70 80 90 100
95 85 75 65 55
45 35 25 15 11
In: Computer Science
Assignment 1 (assessment worth 10%)
Due Date Monday 8th May by 5pm GMT+8
[Submission will be strictly observed. Make submission via Turnitin]
Question 1
An Australian investor holds a one month long forward position on USD. The contract calls for the investor to buy USD 2 million in one month’s time at a delivery price of $1.4510 per USD. The current forward price for delivery in one month is F= $1.5225 per USD. Suppose the current interest rate interest is 5%. What is the value of the investor’s position?
Question 2
A speculator can choose between buying 100 shares of a stock for $40 per share or buying 1000 European call options on the stock with a strike price of $45 for $4 per option. For the second alternative to provide a superior payoff to the first alternative at option maturity, must the stock price be above $50 or below $50 explain?
Question 3
Explain in detail the difference between the following terms:
(a) Intrinsic value of an option.
(b) Price of an option.
(c) Exercise price of an option.
In: Finance
7. Use the substitution & method of INSERT command to populate EMP_PROJ table. INSERT INTO EMP_PROJ VALUES (‘&empNo’, ‘&projNo’, &hoursWorked); NOTE: enclose &empNo in ‘ ‘ if the datatype is a string – VARCHAR2 or CHAR If empNo is NUMBER datatype then do not enclose &empNo in ‘ ‘!
|
empNo |
projNo |
hoursWorked |
|
1000 |
30 |
32.5 |
|
1000 |
50 |
7.5 |
|
2002 |
10 |
40.0 |
|
1444 |
20 |
20.0 |
|
1760 |
10 |
5.0 |
|
1760 |
20 |
10.0 |
|
1740 |
50 |
15.0 |
|
2060 |
40 |
12.0 |
In: Computer Science
Seastrand Oil Company produces two grades of gasoline: regular and high octane. Both gasolines are produced by blending two types of crude oil. Although both types of crude oil contain the two important ingredients required to produce both gasolines, the percentage of important ingredients in each type of crude oil differs, as does the cost per gallon. The percentage of ingredients A and B in each type of crude oil and the cost per gallon are shown.
Crude Oil Cost Ingredient A
Ingredient B
1 $0.10 20% 60%
2 $0.15 50% 30%
Each gallon of regular gasoline must contain at least 40% of
ingredient A, whereas each gallon of high octane can contain at
most 50% of ingredient B. Daily demand for regular and high-octane
gasoline is 900,000 and 700,000 gallons, respectively. How many
gallons of each type of crude oil should be used in the two
gasolines to satisfy daily demand at a minimum cost? Round your
answers to the nearest whole number. Round the answers for cost to
the nearest dollar.
gallons of crude 1 used to produce regular
=
gallons of crude 1 used to produce high-octane
=
gallons of crude 2 used to produce regular
=
gallons of crude 2 used to produce high-octane
=
Cost = $
In: Economics