I am implementing a generic List class and not getting the expected output.
My current output is: [0, 1, null]
Expected Output in a separate test class:
List list = new SparseList<>();
list.add("0");
list.add("1");
list.add(4, "4");
will result in the following list of size 5: [0, 1, null, null, 4].
list.add(3, "Three");
will result in the following list of size 6: [0, 1, null, Three, null, 4].
list.set(3, "Three");
is going to produce a list of size 5 (unchanged): [0, 1, null, Three, 4].
When removing an element from the list above, via list.remove(1); the result should be the following list of size 4: [0, null, Three, 4]
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
public class SparseList<E> implements List<E>{
private int endIndex = 0;
private HashMap<Integer,E> list;
public SparseList() {
list = new HashMap<>();
}
public SparseList(E[] arr) {
list = new HashMap<>();
for(int i = 0; i <arr.length; i++) {
list.put(i, arr[i]);
}
endIndex = arr.length - 1;
}
@Override
public boolean add(E e) {
list.put(endIndex, e);
endIndex++;
return true;
}
@Override
public void add(int index, E element) {
list.put(index, element);
}
@Override
public E remove(int index) {
return list.remove(index);
}
@Override
public E get(int index) {
return list.get(index);
}
@Override
public E set(int index, E element) {
E previous = list.get(index);
list.put(index, element);
return previous;
}
@Override
public int size() {
return endIndex + 1;
}
@Override
public void clear() {
list.clear();
}
@Override
public boolean isEmpty() {
return list.isEmpty();
}
@Override
public String toString() {
String s = "";
for(int i = 0; i < list.size(); i++) {
if(list.get(i) == null) {
s += "null, ";
}else {
s += list.get(i).toString() + ", ";
}
}
return "[" + s + "]";
}
@Override
public boolean contains(Object o) {
throw new UnsupportedOperationException();
}
@Override
public Iterator<E> iterator() {
throw new UnsupportedOperationException();
}
@Override
public Object[] toArray() {
throw new UnsupportedOperationException();
}
@Override
public <T> T[] toArray(T[] a) {
throw new UnsupportedOperationException();
}
@Override
public boolean containsAll(Collection<?> c) {
throw new UnsupportedOperationException();
}
@Override
public boolean addAll(Collection<? extends E> c) {
throw new UnsupportedOperationException();
}
@Override
public boolean addAll(int index, Collection<? extends E> c) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(Collection<?> c) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(Collection<?> c) {
throw new UnsupportedOperationException();
}
@Override
public boolean remove(Object o) {
throw new UnsupportedOperationException();
}
@Override
public int indexOf(Object o) {
throw new UnsupportedOperationException();
}
@Override
public int lastIndexOf(Object o) {
throw new UnsupportedOperationException();
}
@Override
public ListIterator<E> listIterator() {
throw new UnsupportedOperationException();
}
@Override
public ListIterator<E> listIterator(int index) {
throw new UnsupportedOperationException();
}
@Override
public List<E> subList(int fromIndex, int toIndex) {
throw new UnsupportedOperationException();
}
}In: Computer Science
I am implementing a generic List class and not getting the expected output.
My current output is: [0, 1, null]
Expected Output in a separate test class:
List list = new SparseList<>();
list.add("0");
list.add("1");
list.add(4, "4");
will result in the following list of size 5: [0, 1, null, null, 4].
list.add(3, "Three");
will result in the following list of size 6: [0, 1, null, Three, null, 4].
list.set(3, "Three");
is going to produce a list of size 5 (unchanged): [0, 1, null, Three, 4].
When removing an element from the list above, via list.remove(1); the result should be the following list of size 4: [0, null, Three, 4]
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
public class SparseList<E> implements List<E>{
private int endIndex = 0;
private HashMap<Integer,E> list;
public SparseList() {
list = new HashMap<>();
}
public SparseList(E[] arr) {
list = new HashMap<>();
for(int i = 0; i <arr.length; i++) {
list.put(i, arr[i]);
}
endIndex = arr.length - 1;
}
@Override
public boolean add(E e) {
list.put(endIndex, e);
endIndex++;
return true;
}
@Override
public void add(int index, E element) {
list.put(index, element);
}
@Override
public E remove(int index) {
return list.remove(index);
}
@Override
public E get(int index) {
return list.get(index);
}
@Override
public E set(int index, E element) {
E previous = list.get(index);
list.put(index, element);
return previous;
}
@Override
public int size() {
return endIndex + 1;
}
@Override
public void clear() {
list.clear();
}
@Override
public boolean isEmpty() {
return list.isEmpty();
}
@Override
public String toString() {
String s = "";
for(int i = 0; i < list.size(); i++) {
if(list.get(i) == null) {
s += "null, ";
}else {
s += list.get(i).toString() + ", ";
}
}
return "[" + s + "]";
}
@Override
public boolean contains(Object o) {
throw new UnsupportedOperationException();
}
@Override
public Iterator<E> iterator() {
throw new UnsupportedOperationException();
}
@Override
public Object[] toArray() {
throw new UnsupportedOperationException();
}
@Override
public <T> T[] toArray(T[] a) {
throw new UnsupportedOperationException();
}
@Override
public boolean containsAll(Collection<?> c) {
throw new UnsupportedOperationException();
}
@Override
public boolean addAll(Collection<? extends E> c) {
throw new UnsupportedOperationException();
}
@Override
public boolean addAll(int index, Collection<? extends E> c) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(Collection<?> c) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(Collection<?> c) {
throw new UnsupportedOperationException();
}
@Override
public boolean remove(Object o) {
throw new UnsupportedOperationException();
}
@Override
public int indexOf(Object o) {
throw new UnsupportedOperationException();
}
@Override
public int lastIndexOf(Object o) {
throw new UnsupportedOperationException();
}
@Override
public ListIterator<E> listIterator() {
throw new UnsupportedOperationException();
}
@Override
public ListIterator<E> listIterator(int index) {
throw new UnsupportedOperationException();
}
@Override
public List<E> subList(int fromIndex, int toIndex) {
throw new UnsupportedOperationException();
}
}
In: Computer Science
Case Study 2
Read the case study given below and use your knowledge to answer the questions that follow. Examples are to be provided in places where possible.
EBIT-EPS Analysis and Choice of Capital Structure
The current COVID 19 pandemic showed a huge increase in the demand for Personal Protective Equipment’s (PPE) that included face masks, N95 respirators and medical clothing. Xixian Ltd that specialises in production of N95 respirators had stocks of the N95 respirators which were all purchased by health departments and people within two weeks after the outbreak of Coronavirus and this taught a lesson to Xixian Limited to produce the N95 respirators in huge amounts for any sudden future needs.
With the current capacity of its manufacturing plants, it is very difficult to produce a high quantity of the respirators so Xixian Limited is now considering to buy a bigger respirator producing plant that would cost them $2 million. This new investment is expected to generate a permanent increase in the earnings before interest and taxes of $400,000 per annum. The current earnings before interest and taxes is $0.8million. Xixian Limited’s current capital structure consists of contracted debt and equity. The company has 0.1 million preference shares which are traded in the market for $16 each and pay a fixed annual dividend of 8%. Xixian Limited’s contracted debt comprises of $1,500,000 of issued bonds that pays 14% per annum. The firm currently has 0.45 million ordinary shares have been issued and are trading at $20 per share. The tax regulation mandates a 25.00% corporate tax rate for Xixian Limited. Required:
a) To fund the acquisition of the new ‘bigger respirator producing plant’ entirely, Xixian Limited can issue new ordinary shares (New Equity Plan) at the current market price. What is the impact on EPS if new shares are issued to fund the expansion?
b) To fund the acquisition of the new ‘bigger respirator producing plant’ entirely, Xixian Limited can raise new debt at 17.00% interest rate (New Debt Plan). What is the impact on EPS of using debt rather than a new equity issue?
c) Calculate the EPS indifference point of New Equity plan and New Debt Plan
d) Comment on the level of Financial Risk of choosing the New Debt Capital structure over the New Equity Capital structure.
In: Finance
The paint used to make lines on roads must reflect enough light to be clearly visible at night. Let μ denote the true average reflectometer reading for a new type of paint under consideration. A test of H0: μ = 20 versus Ha: μ > 20 will be based on a random sample of size n from a normal population distribution. What conclusion is appropriate in each of the following situations? (Round your P-values to three decimal places.)
(a) n = 19, t = 3.3,
α = 0.05
P-value =
State the conclusion in the problem context.
Reject the null hypothesis. There is not sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20. Do not reject the null hypothesis. There is not sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20. Reject the null hypothesis. There is sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20. Do not reject the null hypothesis. There is sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
(b) n = 8, t = 1.7,
α = 0.01
P-value =
State the conclusion in the problem context.
Reject the null hypothesis. There is not sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20. Do not reject the null hypothesis. There is sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20. Do not reject the null hypothesis. There is not sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20. Reject the null hypothesis. There is sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
(c) n = 25,
t = −0.3
P-value =
State the conclusion in the problem context.
Do not reject the null hypothesis. There is not sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20. Reject the null hypothesis. There is not sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20. Do not reject the null hypothesis. There is sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20. Reject the null hypothesis. There is sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
You may need to use the appropriate table in the Appendix of Tables
to answer this question.
In: Statistics and Probability
The paint used to make lines on roads must reflect enough light to be clearly visible at night. Let μ denote the true average reflectometer reading for a new type of paint under consideration. A test of H0: μ = 20 versus Ha: μ > 20 will be based on a random sample of size n from a normal population distribution. What conclusion is appropriate in each of the following situations? (Round your P-values to three decimal places.)
(a) n = 15, t = 3.3,
α = 0.05
P-value =
State the conclusion in the problem context.
Reject the null hypothesis. There is not sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
Reject the null hypothesis. There is sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
Do not reject the null hypothesis. There is sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
Do not reject the null hypothesis. There is not sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
(b) n = 9, t = 1.7,
α = 0.01
P-value =
State the conclusion in the problem context.
Reject the null hypothesis. There is not sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
Do not reject the null hypothesis. There is sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
Do not reject the null hypothesis. There is not sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
Reject the null hypothesis. There is sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
(c) n = 29,
t = −0.3
P-value =
State the conclusion in the problem context.
Reject the null hypothesis. There is sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
Reject the null hypothesis. There is not sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
Do not reject the null hypothesis. There is not sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
Do not reject the null hypothesis. There is sufficient evidence to conclude that the new paint has a reflectometer reading higher than 20.
In: Math
Photochronograph Corporation (PC) manufactures time series
photographic equipment. It is currently at its target debt-equity
ratio of .76. It’s considering building a new $66.6 million
manufacturing facility. This new plant is expected to generate
aftertax cash flows of $7.91 million in perpetuity. There are three
financing options:
a. A new issue of common stock: The required return on the
company’s new equity is 15.4 percent.
b. A new issue of 20-year bonds: If the company issues these new
bonds at an annual coupon rate of 7.5 percent, they will sell at
par.
c. Increased use of accounts payable financing: Because this
financing is part of the company’s ongoing daily business, the
company assigns it a cost that is the same as the overall firm
WACC. Management has a target ratio of accounts payable to
long-term debt of .13.
(Assume there is no difference between the pretax and aftertax
accounts payable cost.) If the tax rate is 21 percent, what is the
NPV of the new plant? (A negative answer should be indicated by a
minus sign. Do not round intermediate calculations and enter your
answer in dollars, not millions of dollars, rounded to 2 decimal
places, e.g., 1,234,567.89.)
In: Accounting
Question 1 :
Suppose country A and country B are deciding whether to install new incinerator to reduce regional air pollution or not. The new incinerators can reduce the domestic pollution and the cross-border pollution that affects both countries.
To quantify the analysis, suppose that if country A installs the new incinerator, it generates benefit of $1 million from reducing domestic pollution and of $1 million from reducing cross-border pollution. But, the benefit from reducing cross-border pollution will be equally shared by two countries. So, country A and country B will get a benefit of $0.5 million from reducing cross border pollution if country A installs the new incinerator.
The same calculation applies to country B. In other words, the new incinerator generates $1 million benefits domestically in B, and $1 million shared benefits to both A and B (each country gets $0.5 million)
a) Suppose that there is no cost in installing the new incinerator. Draw the game matrix and determine the equilibrium.
b) Suppose that the cost of installing the new incinerator is $2 million, draw the game matrix again. What is the implication from the equilibrium?
In: Economics
The New York City subway station needs a modern transport solution for accessing a busy maintenance depot that services the L train. A second-hand system will cost $60,000; a new system will cost \$135,000. Both systems have a useful life of 6 years. The market value of the used system is expected to be $45,000 at the end of the useful lifetime, whereas the market value of the new system is anticipated to be $55,000 in 6 years. Current maintenance activity will require the used system to be operated 7 hours per day for 25 days per month. The new system with improved technology can decrease labor hours by 17%, compared to the used system. If labor costs $35 per hour and the MARR is 1% per month, calculate the difference between the annual worth of the used system and the new system (e.g., AW(Used System) – AW (New System)). If you believe the new system has a greater worth than the used system, this would be a negative number; if you believe the used system has greater worth, this would be a positive number. Report your answer to the nearest dollar.
In: Accounting
Photochronograph Corporation (PC) manufactures time series photographic equipment. It is currently at its target debt–equity ratio of .60. It’s considering building a new $71.5 million manufacturing facility. This new plant is expected to generate aftertax cash flows of $7.9 million in perpetuity. There are three financing options:
A new issue of common stock: The required return on the company’s new equity is 15.3 percent.
A new issue of 20-year bonds: If the company issues these new bonds at an annual coupon rate of 7 percent, they will sell at par.
Increased use of accounts payable financing: Because this financing is part of the company’s ongoing daily business, the company assigns it a cost that is the same as the overall firm WACC. Management has a target ratio of accounts payable to long-term debt of .12. (Assume there is no difference between the pretax and aftertax accounts payable cost.)
If the tax rate is 35 percent, what is the NPV of the new plant? (A negative answer should be indicated by a minus sign. Do not round intermediate calculations and enter your answer in dollars, not millions of dollars, e.g., 1,234,567. Round your answer to 2 decimal places, e.g., 32.16.)
NPV=
In: Finance
Apricot Computers is considering replacing its material handling
system and either purchasing or leasing a new system. The old
system has an annual operating and maintenance cost of $31,000, a
remaining life of 8 years, and an estimated salvage value of $5,800
at that time.
A new system can be purchased for $237,000; it will be worth
$26,000 in 8 years; and it will have annual operating and
maintenance costs of $19,000/year . If the new system is purchased,
the old system can be traded in for $21,000.
Leasing a new system will cost $22,000/year , payable at the
beginning of the year, plus operating costs of $8,400/year ,
payable at the end of the year. If the new system is leased, the
old system will be sold for $9,400.
MARR is 14%. Compare the annual worths of keeping the old system,
buying a new system, and leasing a new system based upon a planning
horizon of 8 years.
Click here to access the TVM Factor Table Calculator
For calculation purposes, use 5 decimal places as
displayed in the factor table provided. Round answer to 2 decimal
places, e.g. 52.75. The absolute cell tolerance is
±1
What is the EUAC of the best option using the cash flow approach?
In: Accounting