This is a java problem. Complete and only modify ArrayQueue.java and CircularLinkedQueue.java.
Use Homework3Driver.java to test correctness of implementation of both.
This package includes Homework3Driver.java, QueueInterface.java, QueueOverflowException.java, QueueUnderflowException.java, and LLNode.java Do NOT modify any of those files.
The final output should be:
"For ArrayQueue.java, you get 30/30
For CircularLinkedQueue.java, you get 20/20
Your final score is 50/50"
This is ArrayQueue.java (the one that should be modified):
public class ArrayQueue<T> implements
QueueInterface<T> {
private static int CAPACITY = 100;
private T[] elements;
private int rearIndex = -1;
// Default constructor to initialize array capacity
with CAPACITY
public ArrayQueue() {
}
// Constructor to initialize array capacity with
'size'
@SuppressWarnings("unchecked")
public ArrayQueue(int size) {
}
// Dequeue info from array. Throw
QueueUnderflowException if array is empty
public T dequeue() {
}
// Enqueue info into array. Throw
QueueOverflowException if array is full
public void enqueue(T info) {
}
// Return true if the array is empty; otherwise
return false
public boolean isEmpty() {
}
// Return true if the array is full; otherwise
return false
public boolean isFull() {
}
// Return number of elements
public int size() {
}
// Adjust elements array capacity with 'size'
public void resize(int size) {
}
// Return array capacity
public int getQueueCapacity() {
}
}
This is CircularLinkedQueue.java (The one that should also be modified):
// Note: It is important to implement this file as a circular
queue without 'front' pointer
public class CircularLinkedQueue<T> implements
QueueInterface<T> {
protected LLNode<T> rear; // reference to the
rear of this queue
protected int numElements = 0; // number of elements
in this queue
public CircularLinkedQueue() {
}
public void enqueue(T element)
// Adds element to the rear of this queue.
{
}
public T dequeue()
// Throws QueueUnderflowException if this queue is
empty;
// otherwise, removes front element from this queue
and returns it.
{
}
public String toString() {
String result = "";
return result;
}
public boolean isEmpty()
// Returns true if this queue is empty; otherwise,
returns false.
{
}
public boolean isFull()
// Returns false - a linked queue is never full.
{
}
public int size()
// Returns the number of elements in this queue.
{
}
}
This is Homework3Driver.java (the one to use to test the implementation of ArrayQueue.java and CircularLinkedQueue.java. Do not modify this file):
public class Homework3Driver {
public static void main(String[] args) {
int score = 0;
// Part 1: Array Based
queue
score += testArrayQueue();
System.out.printf("For
ArrayQueue.java, you get %d/30\n", testArrayQueue());
// Part 2: Circular Queue
score +=
testCircularLinkedQueue();
System.out.printf("For
CircularLinkedQueue.java, you get %d/20\n",
testCircularLinkedQueue());
System.out.printf("Your final
score is %d/50 \n", score);
}
private static int testArrayQueue() {
int score = 0;
ArrayQueue<Character> c =
new ArrayQueue<Character>();
if (c.getQueueCapacity() ==
100)
score += 1;
ArrayQueue<String> q = new
ArrayQueue<String>(2);
if (q.getQueueCapacity() ==
2)
score += 1;
try {
q.dequeue(); //
Note: Underflow exception should occur
} catch (Exception e) {
score +=
3;
}
if (q.isEmpty() &&
!q.isFull() && q.size() == 0)
score += 5;
q.enqueue("Orange");
q.enqueue("Mango");
try {
q.enqueue("Guava"); // Note: with Queue size 2, this won't get into
the queue.
} catch (Exception e) {
score +=
3;
}
if (q.isFull())
score += 2;
if (q.dequeue().equals("Orange")
&& q.size() == 1 && !q.isEmpty())
score += 3;
if (q.dequeue().equals("Mango")
&& q.size() == 0 && q.isEmpty())
score += 2;
q.enqueue("Strawberry");
q.enqueue("Lemon");
q.resize(2); // Increase the array
size by 2
q.enqueue("Banana");
if (q.getQueueCapacity() == 4
&& q.size() == 3 && !q.isEmpty() &&
!q.isFull())
score += 5;
q.resize(-1); // Decrease the
array size by 1.
if (q.getQueueCapacity() == 3
&& q.size() == 3 && !q.isEmpty() &&
q.isFull())
score += 5;
return score;
}
private static int testCircularLinkedQueue() {
int score = 0;
CircularLinkedQueue<String>
cq = new CircularLinkedQueue<String>();
try {
System.out.println(cq.dequeue());
} catch (Exception e) {
if (cq.size() ==
0 && cq.isEmpty() && !cq.isFull())
score +=
5;
}
cq.enqueue("Tomato");
cq.enqueue("Grape");
if (cq.size() == 2 &&
!cq.isEmpty() && !cq.isFull())
score += 5;
cq.dequeue();
cq.dequeue();
if (cq.size() == 0 &&
cq.isEmpty() && !cq.isFull())
score +=
5;
cq.enqueue("Pineapple");
cq.enqueue("Lime");
// System.out.println(cq);
// Note: Implement toString()
method to match this output.
if
(cq.toString().equals("Pineapple\nLime\n"))
score += 5;
return score;
}
}
This is QueueInterface.java (Do not modify):
public interface QueueInterface<T> {
void enqueue(T element) throws
QueueOverflowException;
// Throws QueueOverflowException if this queue is
full;
// otherwise, adds element to the rear of this
queue.
T dequeue() throws QueueUnderflowException;
// Throws QueueUnderflowException if this queue is
empty;
// otherwise, removes front element from this queue
and returns it.
boolean isFull();
// Returns true if this queue is full; otherwise,
returns false.
boolean isEmpty();
// Returns true if this queue is empty; otherwise,
returns false.
int size();
// Returns the number of elements in this queue.
}
This is LLNode.java (do not modify):
public class LLNode<T> {
protected LLNode<T> link;
protected T info;
public LLNode(T info) {
this.info = info;
link = null;
}
public void setInfo(T info) {
this.info = info;
}
public T getInfo() {
return info;
}
public void setLink(LLNode<T> link) {
this.link = link;
}
public LLNode<T> getLink() {
return link;
}
}
This is QueueOverflowException.java (do not modify):
public class QueueOverflowException extends RuntimeException
{
private static final long serialVersionUID = 1L;
public QueueOverflowException() {
super();
}
public QueueOverflowException(String message)
{
super(message);
}
}
This is QueueUnderflowException.java (do not modify):
public class QueueUnderflowException extends RuntimeException
{
private static final long serialVersionUID = 1L;
public QueueUnderflowException() {
super();
}
public QueueUnderflowException(String message)
{
super(message);
}
}
In: Computer Science
GTA Construction Corporation constructed two buildings near the San Andreas fault line. The probability that either of these buildings will experience an earthquake is 4.6 percent. However, if one building experiences an earthquake, the probability that the second building will experience an earthquake is 57 percent. What is the probability (in percent) that both buildings will experience earthquake damage?
IMB Computing creates motherboards for cellphones at their campuses in Seattle and San Diego. The company is worried about computer hackers and hired a consultant to evaluate their risk. The consultant estimated that the San Diego campus has a 12.1 percent chance of being hacked. The consultant also noted that the Seattle location has a 24.4 percent chance of digital hacking. IMB would asks the consultant, what is the probability (in percent) that both campuses will suffer hacking related crime in any given year?
Hishiba Company assembles hard drives and has plants in both the South and the North, spaced about 3,000 miles apart and connected by light rail. Hishiba is worried about local rain causing flooding at their plants. The probability that in any given year a flood will damage the North plant 5.1 percent. The probability that in any given year a flood will damage the South plant is 13 percent. What is the probability (in percent) that at least one of the plants will be damaged by flood in any given year?
In: Advanced Math
Let x be a random variable that represents the level of glucose in the blood (milligrams per deciliter of blood) after a 12 hour fast. Assume that for people under 50 years old, x has a distribution that is approximately normal, with mean μ = 56 and estimated standard deviation σ = 42. A test result x < 40 is an indication of severe excess insulin, and medication is usually prescribed.
A.) What is the probability that, on a single test, x < 40? (Round your answer to three decimal places.)
B.) Suppose a doctor uses the average x for two tests taken about a week apart. What can we say about the probability distribution of x?
The probability distribution of x is not normal.
The probability distribution of x is approximately normal with μx = 56 and σx = 21.00.
The probability distribution of x is approximately normal with μx = 56 and σx = 29.70.
The probability distribution of x is approximately normal with μx = 56 and σx = 42.
What is the probability that x < 40? (Round your answer to three decimal places.)
C.) Repeat part (b) for n = 3 tests taken a week apart. (Round your answer to three decimal places.)
D.) Repeat part (b) for n = 5 tests taken a week apart. (Round your answer to three decimal places.)
In: Statistics and Probability
We will use shorthand notation and probability notation for random variables when working with normally distributed random variables. Suppose the vitamin C content of a particular variety of orange is distributed normally with mean 720 IU and standard deviation 46 IU. If we designate
X = the vitamin C content of a randomly selected orange,
then our shorthand notation is
X~N(720 IU, 46 IU).
Use this distribution of vitamin C content to answer the following questions:
1) What is the probability that a randomly selected orange will have less than 660 IU? Using X as the random variable, state your answer as a probability statement using the probability notation developed in the learning module.
2) What is the 80th percentile of the of the distribution of vitamin C content of the oranges?
3) What proportion of oranges exceed the vitamin C content you found in part (2) above?
4) What range of vitamin C content values represent the middle 80% of the distribution? State your answer as a probability statement using the probability notation developed in the learning module.
5) Suppose Y~N( 280 mg, 20 mg). Find Y1such that P( Y > Y1) = 0.0250. State your answer in the form of a complete sentence without using any probability notation.
In: Statistics and Probability
Let x be a random variable that represents the level of glucose in the blood (milligrams per deciliter of blood) after a 12-hour fast. Assume that for people under 50 years old, x has a distribution that is approximately normal, with mean μ = 71 and estimated standard deviation σ = 35. A test result x < 40 is an indication of severe excess insulin, and medication is usually prescribed.
(a) What is the probability that, on a single test, x
< 40? (Round your answer to four decimal places.)
(b) Suppose a doctor uses the average x for two tests
taken about a week apart. What can we say about the probability
distribution of x? Hint: See Theorem 7.1.
The probability distribution of x is not normal.The probability distribution of x is approximately normal with μx = 71 and σx = 35. The probability distribution of x is approximately normal with μx = 71 and σx = 17.50.The probability distribution of x is approximately normal with μx = 71 and σx = 24.75.
What is the probability that x < 40? (Round your answer
to four decimal places.)
(c) Repeat part (b) for n = 3 tests taken a week apart.
(Round your answer to four decimal places.)
(d) Repeat part (b) for n = 5 tests taken a week
apart.
In: Statistics and Probability
Pay your taxes: According to the Internal Revenue Service, the proportion of federal tax returns for which no tax was paid was =p0.326. As part of a tax audit, tax officials draw a simple sample of =n140 tax returns. Use Cumulative Normal Distribution Table as needed. Round your answers to at least four decimal places if necessary.
Part 1 of 4
(a)What is the probability that the sample proportion of tax returns for which no tax was paid is less than 0.29?
| The probability that the sample proportion of tax returns for which no tax was paid is less than 0.29 is ____ |
Part 2 of 4
(b)What is the probability that the sample proportion of tax returns for which no tax was paid is between 0.36 and 0.43?
| The probability that the sample proportion of tax returns for which no tax was paid is between 0.36 and 0.43 is ____ |
Part 3 of 4
(c)What is the probability that the sample proportion of tax returns for which no tax was paid is greater than 0.32?
| The probability that the sample proportion of tax returns for which no tax was paid is greater than 0.32 is ____ |
Part 4 of 4
(d)Would it be unusual if the sample proportion of tax returns for which no tax was paid was less than 0.23?
| It ▼(Would/Would not) be unusual if the sample proportion of tax returns for which no tax was paid was less than 0.23, since the probability is ____. |
In: Math
1.
|
A recent survey reported in BusinessWeek dealt with the salaries of CEOs at large corporations and whether company shareholders made money or lost money. |
| CEO Paid More Than $1 Million |
CEO Paid Less Than $1 Million |
Total | |
| Shareholders made money | 6 | 15 | 21 |
| Shareholders lost money | 8 | 4 | 12 |
| Total | 14 | 19 | 33 |
|
If a company is randomly selected from the list of 33 studied, calculate the probabilities for the following : |
| (a) | The CEO made more than $1 million. (Round your answers to 3 decimal places.) |
| Probability |
| (b) |
The CEO made more than $1 million or the shareholders lost money. (Round your answers to 3 decimal places.) |
| Probability |
| (c) |
The CEO made more than $1 million given the shareholders lost money. (Round your answers to 3 decimal places.) |
| Probability |
| (d) |
Select 2 CEOs and find that they both made more than $1 million. (Round your answers to 3 decimal places.) |
| Probability |
2.
|
The probability a HP network server is down is .062. If you have four independent servers, what is the probability that at least one of them is operational? (Round your answer to 6 decimal places.) |
| Probability |
In: Math
Wingler Communications Corporation (WCC) produces premium stereo headphones that sell for $28.60 per set, and this year's sales are expected to be 450,000 units. Variable production costs for the expected sales under present production methods are estimated at $10,500,000, and fixed production (operating) costs at present are $1,560,000. WCC has $4,800,000 of debt outstanding at an interest rate of 8%. There are 240,000 shares of common stock outstanding, and there is no preferred stock. The dividend payout ratio is 70%, and WCC is in the 40% federal-plus-state tax bracket.
The company is considering investing $7,200,000 in new equipment. Sales would not increase, but variable costs per unit would decline by 20%. Also, fixed operating costs would increase from $1,560,000 to $1,800,000. WCC could raise the required capital by borrowing $7,200,000 at 10% or by selling 240,000 additional shares of common stock at $30 per share.
On the basis of the analysis in parts a through c, and given that operating leverage is lower under the new setup, which plan is the riskiest, which has the highest expected EPS, and which would you recommend? Assume here that there is a fairly high probability of sales falling as low as 250,000 units, and determine EPSDebt and EPSStock at that sales level to help assess the riskiness of the two financing plans. Do not round intermediate calculations. Round your answers to two decimal places. Negative amount should be indicated by a minus sign.
In: Finance
The table below shows the number of male and female students enrolled in nursing at a university for a certain semester. A student is selected at random. Complete parts (a) through (d).
| Nursing majors | Non-nursing majors | Total | |
|---|---|---|---|
| Males | 98 | 1016 | 1114 |
| Females | 600 | 1729 | 2329 |
| Total | 696 | 2745 | 3443 |
(c) Find the probability that the student is not female or a nursing major.
P(not being female or being a nursing major)=_______
Round to the nearest thousandth as needed.)
(d) Are the events "being male" and "being a nursing major" mutually exclusive? Explain.
A. Yes, because one can't be male and a nursing major at the same time.
B. Yes, because there are 98 males majoring in nursing
C. No, because there are 98 males majoring in nursing
D. No, because one cant be male and a nursing mayor at the same time.
In: Math
In a recent year, the Better Business Bureau settled 75% of complaints they received. (Source: USA Today, March 2, 2009) You have been hired by the Bureau to investigate complaints this year involving computer stores. You plan to select a random sample of complaints to estimate the proportion of complaints the Bureau is able to settle. Assume the population proportion of complaints settled for the computer stores is the 0.75, as mentioned above. Suppose your sample size is 146. What is the probability that the sample proportion will be within 9 percentage points of the population proportion?
(Tip: If you compute the standard error [i.e. the standard deviation of the sampling distribution], round it to 4 digits if you have to use it in later computations.)
Answer = (Enter your answer as a number accurate to 4
decimal places.)
In: Statistics and Probability