A survey showed that 79% of adults need correction (eyeglasses, contacts, surgery, etc.) for their eyesight. If 20 adults are randomly selected, find the probability that no more than 1 of them need correction for their eyesight. Is 1 a significantly low number of adults requiring eyesight correction? The probability that no more than 1 of the 20 adults require eyesight correction is nothing.
In: Math
Create MySortedArrayCollection.java
****** Make new and just complete MySortedArrayCollection.java, dont modify others
////////////////////////////////////////////////////////
SortedArrayCollection.java
public class SortedArrayCollection<T> implements
CollectionInterface<T> {
protected final int DEFCAP = 100; // default
capacity
protected int origCap; // original capacity
protected T[] elements; // array to hold collection
elements
protected int numElements = 0; // number of elements
in this collection
// set by find method
protected boolean found; // true if target found,
otherwise false
protected int location; // indicates location of
target if found,
// indicates add index if not found
public SortedArrayCollection() {
elements = (T[]) new
Object[DEFCAP];
origCap = DEFCAP;
}
public SortedArrayCollection(int capacity) {
elements = (T[]) new
Object[capacity];
this.origCap = capacity;
}
protected void enlarge()
// Increments the capacity of the collection by an
amount
// equal to the original capacity.
{
// Create the larger array.
T[] larger = (T[]) new
Object[elements.length + origCap];
// Copy the contents from the
smaller array into the larger array.
for (int i = 0; i < numElements;
i++) {
larger[i] =
elements[i];
}
// Reassign elements
reference.
elements = larger;
}
protected void find(T target)
// Searches elements for an occurrence of an element e
such that
// e.equals(target). If successful, sets instance
variables
// found to true and location to the array index of e.
If
// not successful, sets found to false and location to
the
// array index where target should be inserted.
{
location = 0;
found = false;
if (!isEmpty())
recFind(target,
0, numElements - 1);
}
protected void recFind(T target, int first, int
last)
// Used by find.
{
int result; // result of the
comparison
if (first > last) {
found =
false;
result =
((Comparable) target).compareTo(elements[location]);
if (result >
0)
location++; // adjust location to indicate
insert index
} else {
location =
(first + last) / 2;
result =
((Comparable) target).compareTo(elements[location]);
if (result == 0)
// found target
found = true;
else if (result
> 0) // target too high
recFind(target, location + 1, last);
else // target
too low
recFind(target, first, location - 1);
}
}
public boolean add(T element)
// Precondition: element is Comparable to previously
added objects
//
// Adds element to this collection.
{
if (numElements ==
elements.length)
enlarge();
find(element); // sets location to index where element belongs
for (int index = numElements;
index > location; index--)
elements[index]
= elements[index - 1];
elements[location] =
element;
numElements++;
return true;
}
public boolean remove(T target)
// Removes an element e from this collection such that
e.equals(target)
// and returns true; if no such element exists,
returns false.
{
find(target);
if (found) {
for (int i =
location; i <= numElements - 2; i++)
elements[i] = elements[i + 1];
elements[numElements - 1] = null;
numElements--;
}
return found;
}
public int size()
// Returns the number of elements on this
collection.
{
return numElements;
}
public boolean contains(T target)
// Returns true if this collection contains an element
e such that
// e.equals(target); otherwise, returns false.
{
find(target);
return found;
}
public T get(T target)
// Returns an element e from this collection such that
e.equals(target);
// if no such element exists, returns null.
{
find(target);
if (found)
return
elements[location];
else
return
null;
}
public boolean isEmpty()
// Returns true if this collection is empty;
otherwise, returns false.
{
return (numElements == 0);
}
public boolean isFull()
// This collection is unbounded so always returns
false.
{
return false;
}
}
///////////////////////////////////////////////////////
MySortedArrayCollectionInterface.java
public interface MySortedArrayCollectionInterface<T>
extends CollectionInterface<T> {
public String toString();
// Creates and returns a string that correctly
represents the current
// collection.
// Such a method could prove useful for testing and
debugging the class and for
// testing and debugging applications that use the
class.
// Assume each stored element already provides its own
reasonable toString
// method.
public T smallest();
// Returns null if the collection is empty, otherwise
returns the smallest
// element of the collection.
public int greater(T element);
// Returns a count of the number of elements e in the
collection that are
// greater then element, that is such that
e.compareTo(element) is > 0
public MySortedArrayCollection<T>
combine(MySortedArrayCollection<T> other);
// Creates and returns a new SortedArrayCollection
object that is a combination
// of this object and the argument object.
public T[] toArray();
// Returns an array containing all of the elements of
the collection.
public void clear();
// Removes all elements.
public boolean equals(Object o);
// Takes an Object argument, returning true if it is
equal to the current
// collection and false otherwise
public boolean
addAll(MySortedArrayCollection<T> c);
// Takes a MySortedArrayCollection argument and adds
its contents to the current
// collection;
// returns a boolean indicating success or
failure.
public boolean
retainAll(MySortedArrayCollection<T> c);
// Takes a MySortedArrayCollection argument and
removes any elements from the
// current collection that are not in the argument
collection; returns a boolean
// indicating success or failure.
public void
removeAll(MySortedArrayCollection<T> c);
// Takes a MySortedArrayCollection argument and
removes any elements from the
// current collection that are also in the argument
collection.
}
//////////////////////////////////////////////
CollectionInterface.java
public interface CollectionInterface<T> {
boolean add(T element);
// Attempts to add element to this collection.
// Returns true if successful, false otherwise.
T get(T target);
// Returns an element e from this collection such that
e.equals(target).
// If no such e exists, returns null.
boolean contains(T target);
// Returns true if this collection contains an element
e such that
// e.equals(target); otherwise returns false.
boolean remove(T target);
// Removes an element e from this collection such that
e.equals(target)
// and returns true. If no such e exists, returns
false.
boolean isFull();
// Returns true if this collection is full; otherwise,
returns false.
boolean isEmpty();
// Returns true if this collection is empty;
otherwise, returns false.
int size();
// Returns the number of elements in this
collection.
}
In: Computer Science
Snow White recieves a basket of 11 apples, out of which 2 of
them are poisoned. She decides to eat 4 of them. Let X1 denote the
number of unpoisoned apples that she eats.
Check all that are true about X1.
A. We can model X1 with a collection of
trials
B. The trials are independent
C. The trials have two outcomes
D. The trials have the same probability of
success.
E. There are a set number of trials
Snow White recieves an unlimited basket of apples, each of which
has a 0.4 chance of being poisoned, regardless of the status of
other apples. She makes the questionable choice to keep eating them
until she eats a poisoned one. Let X2 denote the number of
unpoisoned apples that she eats.
Check all that are true about X2.
A. The trials have two outcomes
B. We can model X2 with a collection of
trials
C. There are a set number of trials
D. The trials are independent
E. The trials have the same probability of
success.
Snow White recieves a basket of 4 apples, all of whom are either
poisoned or not. There is a 0.4 chance they are poisoned. She
decides to eat all of them. Let X3 denote the number of unpoisoned
apples that she eats.
Check all that are true about X3.
A. The trials have the same probability of
success.
B. There are a set number of trials
C. The trials are independent
D. We can model X3 with a collection of
trials
E. The trials have two outcomes
Snow White recieves a basket of 4 apples, each of which has a 0.4
chance of being poisoned, regardless of the status of other apples.
She decides to eat all of them. Let X4 denote the number of
unpoisoned apples that she eats.
Check all that are true about X4.
A. The trials are independent
B. We can model X4 with a collection of
trials
C. The trials have two outcomes
D. There are a set number of trials
E. The trials have the same probability of
success.
Which of the following are a binomial random variable?
A. X1
B. X2
C. X4
D. X3
In: Statistics and Probability
Snow White recieves a basket of 11 apples, out of which 3 of
them are poisoned. She decides to eat 5 of them. Let X1denote the
number of unpoisoned apples that she eats.
Check all that are true about X1.
A. The trials are independent
B. The trials have two outcomes
C. The trials have the same probability of
success.
D. There are a set number of trials
E. We can model X1 with a collection of
trials
Snow White recieves an unlimited basket of apples, each of which
has a 0.4 chance of being poisoned, regardless of the status of
other apples. She makes the questionable choice to keep eating them
until she eats a poisoned one. Let X2 denote the number of
unpoisoned apples that she eats.
Check all that are true about X2.
A. The trials have two outcomes
B. We can model X2 with a collection of
trials
C. The trials have the same probability of
success.
D. The trials are independent
E. There are a set number of trials
Snow White recieves a basket of 5 apples, all of whom are either
poisoned or not. There is a 0.4 chance they are poisoned. She
decides to eat all of them. Let X3 denote the number of unpoisoned
apples that she eats.
Check all that are true about X3.
A. The trials have two outcomes
B. There are a set number of trials
C. We can model X3 with a collection of
trials
D. The trials have the same probability of
success.
E. The trials are independent
Snow White recieves a basket of 5 apples, each of which has a 0.4
chance of being poisoned, regardless of the status of other apples.
She decides to eat all of them. Let X4 denote the number of
unpoisoned apples that she eats.
Check all that are true about X4.
A. The trials are independent
B. We can model X4 with a collection of
trials
C. The trials have the same probability of
success.
D. There are a set number of trials
E. The trials have two outcomes
Which of the following are a binomial random variable?
A. X2
B. X4
C. X3
D. X1
In: Statistics and Probability
Do a hypothesis for the following, make sure to include and label all five steps:
Test the claim that the proportion of wins is the same whether the wear a shirt
and tie or jeans and a t-shirt. Use a .05 significance level.
|
Win |
Loss |
|
|
Suit and Tie |
23 |
38 |
|
Jeans and T-shirt |
28 |
24 |
In: Statistics and Probability
An urn contains 5000 balls, of which 100 are yellow and the remaining are purple. We draw 20 balls from the urn and denote the number of yellow balls drawn by X.
(a) What kind of random variable is X if the draws are performed
without replacement? Write down the probability distribution
function f(x) of X and compute P(X = 5).
(Give an exact expression for the probability that is asked but do
not evaluate!)
(b) What kind of random variable is X if the draws are performed with replacement? Write down the probability distribution function f(x) of X and compute P(X ≤ 2). (Give an exact expression for the probability that is asked but do not evaluate!)
(c) Use Poisson distribution to approximate the probability asked in part (b).
In: Statistics and Probability
A subway train on the Red Line arrives every 8 minutes during rush hour. We are interested in the length of time a commuter must wait for a train to arrive. The time follows a uniform distribution.
A. Enter an exact number as an integer, fraction, or
decimal.
μ =
B. σ = Round your answer to two decimal places.
C. Find the probability that the commuter waits less than one minute.
D. Find the probability that the commuter waits between five and six minutes.
E. State "80% of commuters wait more than how long for the
train?" in a probability question. (Enter your answer to one
decimal place.)
Find the probability that the commuter waits more than __ minutes.
Draw the picture and find the probability.
In: Statistics and Probability
In: Math
A Carnot heat engine receives heat at 850 K and
rejects the waste heat to the environment at 298 K.
The entire work output of the heat engine is used to drive a Carnot
refrigerator that removes heat
from the cooled space at -17⁰C at a rate of 450 kJ/min and rejects
it to the same environment at 298
K. Determine;
(a) the rate of heat supplied to the heat engine and
(b) the total rate of heat rejection to the environment.
In: Physics
an air-conditioner on a hot summer day removes 8 kW of energy at 21°C and pushes energy to the outside which is 31°C. the house has 15000 mg mass with an average specific heat of .95 kJ/mg K. in order to do this, the cold side of the air-conditioner is at 5°C and the hot side is at 40°C the air-conditioner COP of 60%. Find the power to run the air-conditioner
In: Physics