Questions
You are given two arrays A1 and A2, each with n elements sorted in increasing order....

You are given two arrays A1 and A2, each with n elements sorted in increasing order. For simplicity, you may assume that the keys are all distinct from each other. Describe an o(log n) time algorithm to find the (n/2) th smallest of the 2n keys assuming that n is even.

In: Computer Science

Over 1 billion people in the world don’t have access to electricity, relying mostly on fire...

Over 1 billion people in the world don’t have access to electricity, relying mostly on fire for heat and cooking. Discuss the benefits and costs of carbon caps that limit the construction of new power plants in less developed countries.

In: Economics

You are to modify the Pez class so that all errors are handled by exceptions. The...

You are to modify the Pez class so that all errors are handled by exceptions. The constructor must be able to handle invalid parameters. The user should not be able to get a piece of candy when the Pez is empty. The user should not be able to put in more candy than the Pez can hold. I would like you to do 3 types of exceptions. One handled within the class itself, one handled by the calling method and one custom made exception. Be sure to comment in the program identifying each type of exception. You have the freedom of choosing which exception style you use where. You will need to submit 3 files, the Pez class, the custom exception class, and a tester program demonstrating that all of your exceptions work properly.

public class Pez
{
  private int candy;
  private final int MAX_PIECES = 12;
  
  public Pez()
  {
    candy = 0;
  }
  
  public Pez(int pieces) //this will need to be error-proofed
  {
    candy = pieces;
  }
  
  public int getCandy() 
  {
    return candy;
  }
  
  public void setCandy(int pieces) //this will need to be error-proofed
  {
    candy = pieces;
  }
  
  public void getAPieceOfCandy() //this will need to be error-proofed
  {
    candy = candy - 1;
  }
  
  public int fillPez() 
  {
    int piecesNeeded = MAX_PIECES - candy;
    candy = MAX_PIECES;
    return piecesNeeded;
  }
  
  public int emptyPez()
  {
    int currentPieces = candy;
    candy = 0;
    return currentPieces;
  }
  
  public void addPieces(int pieces) //this will need to be error-proofed
  {
      candy = candy + pieces;
  }
 
  public String toString()
  {
    String thisPez = "This Pez has " + candy + " pieces of candy";
    return thisPez;
  }
  
  public boolean equals(Pez pez2)
  {
    if(this.candy == pez2.candy)
      return true;
    return false;
  }
      
}

In: Computer Science

This code must be written in Java. This code also needs to include a package and...

This code must be written in Java. This code also needs to include a package and a public static void main(String[] args)

Write a program named DayOfWeek that computes the day of the week for any date entered by the user. The user will be prompted to enter a month, day, and year. The program will then display the day of the week (Sunday..Saturday). The following example shows what the user will see on the screen:

This program calculates the day of the week for any dates.

Enter month (1-12): 9

Enter day (1-31): 25

Enter year: 1998

The day of the week is Friday.

Hint: Use Zeller's congruence to compute the day of the week. Zeller's congruence relies on the following quantities:

J is the century (19, in our example)

K is the year within the century (98, in our example)

m is the month (9, in our example)

q is the day of the month (25, in our example)

The day of the week is determined by the following formula:

h = (q + 26(m + 1) / 10 + K + K / 4 + J / 4 + 5J) mod 7

where the results of the divisions are truncated. The value of h will lie between 0 (Saturday) and 6 (Friday).

Note: Zeller's congruence assumes that January and February are treated as months 13 and 14 of the previous year; this affects the values of K and m, and possibly the value of J. Note that the value of h does not match the desired output of the program, so some adjustment will be necessary. Apply Exception Handling.

In: Computer Science

Write a program that reads a text file and reports the total count of words of...

Write a program that reads a text file and reports the total count of words of each length. A word is defined as any contiguous set of alphanumeric characters, including symbols. For example, in the current sentence there are 10 words. The filename should be given at the command line as an argument. The file should be read one word at a time. A count should be kept for how many words have a given length. For example, the word “frog” is 4 bytes in length; the word “turtle” is 6 bytes in length. The program should report the total word counts of all lengths between 3 and 15 bytes. Words with lengths outside that range should not be counted

In: Computer Science

19.0-L tank of carbon dioxide gas (CO2) is at a pressure of 9.40 ✕ 105 Pa...

19.0-L tank of carbon dioxide gas (CO2) is at a pressure of 9.40 ✕ 105 Pa and temperature of 18.0°C. (a) Calculate the temperature of the gas in Kelvin. K (b) Use the ideal gas law to calculate the number of moles of gas in the tank. mol (c) Use the periodic table to compute the molecular weight of carbon dioxide, expressing it in grams per mole. g/mol (d) Obtain the number of grams of carbon dioxide in the tank. g (e) A fire breaks out, raising the ambient temperature by 224.0 K while 82.0 g of gas leak out of the tank. Calculate the new temperature and the number of moles of gas remaining in the tank. temperature K number of moles mol (f) Using the ideal gas law, find a symbolic expression for the final pressure, neglecting the change in volume of the tank. (Use the following as necessary: ni, the initial number of moles; nf, the final number of moles; Ti, the initial temperature; Tf, the final temperature; and Pi, the initial pressure.) Pf = (g) Calculate the final pressure in the tank as a result of the fire and leakage. Pa

In: Physics

(1) Explain that a counter-controlled loop is useful when you know how many times a set...

(1) Explain that a counter-controlled loop is useful when you know how many times a set of statements needs to be executed.

(2) Discuss the implementations of the Fibonacci Number program at the end of this section to consolidate the students’ understanding of the while loop repetition structures.

In: Computer Science

Should drug abuse be treated as a crime? Under what situations should the response be diversion...

Should drug abuse be treated as a crime? Under what situations should the response be diversion to treatment rather than incarceration? Should all inmates have access to jail or prison-based drug treatment? Why is there such a difference in response to drug offenders based on their race? What should be done about this?

Please type the answer, do not use handwritten notes. Thanks

In: Psychology

Bond X is noncallable and has 20 years to maturity, a 10% annual coupon, and a...

Bond X is noncallable and has 20 years to maturity, a 10% annual coupon, and a $1,000 par value. Your required return on Bond X is 11%; if you buy it, you plan to hold it for 5 years. You (and the market) have expectations that in 5 years, the yield to maturity on a 15-year bond with similar risk will be 9.5%. How much should you be willing to pay for Bond X today? (Hint: You will need to know how much the bond will be worth at the end of 5 years.) Do not round intermediate calculations. Round your answer to the nearest cent.

In: Finance

Which condition applies to all special needs exceptions?             a. They involve highly regulated businesses.            ...

Which condition applies to all special needs exceptions?

            a. They involve highly regulated businesses.

            b. They are based on probable cause.

            c. They are not initiated by the police.

            d. They are based on good faith.

The right to privacy can be described as a(n) __________.

            a. privilege   

            b. anticipatory expectation        

            c. misnomer

            d. penumbra           

What legal standard applies to a warrantless search of probationer and parolee homes?

            a. anticipatory seizure      

            b. reasonable grounds     

            c. neutral circumstances

            d. reasonable suspicion

In: Psychology

How dangerous is radioactivity? Discuss the real and imagined dangers. Give examples, along with numbers. Which...

How dangerous is radioactivity? Discuss the real and imagined dangers. Give examples, along with numbers. Which risks are known from direct observation, and which are known only from calculations? What assumptions are made in calculating risk?

In: Physics

6. In the 192.168.0.0/16 address block there are a total of __________ IP version 4 addresses....

6. In the 192.168.0.0/16 address block there are a total of __________ IP version 4 addresses.

65,536

16,777,216

4,096

1,048,576

7. Given the IPv4 address and network mask 134.124.133.139/22, identify the broadcast address in that network (the last address). [you may use the ip_addressing_basics spreadsheet, see "IPv4 Address, Network ID, etc." sheet]

134.124.132.0/22

134.124.133.255/22

134.124.132.255/24

134.124.135.255/22

8. Express the CIDR mask /18 using the dotted decimal notation.

255.255.192.0

255.192.0.0

255.255.255.0

255.255.240.0

9.

Host A has IP address/network mask: 192.168.3.222/27

Host B has IP address/network mask: 192.168.3.225/27

Given the information above, it can be inferred that:

Both host A and host B are on the same network

Host A and Host B are on different networks

Host A and Host B will have the same routing tables

Host A and Host B will be able to communicate directly without an intervening router.

10. A Host (the sending host) is trying to send a packet to another host (the destination host). The sending host knows the IP address of destination host. In deciding how to forward the packet toward destination host, the sending host will:

take the Destination IP address and perform a Logical AND operation with its own (sending hosts') Network Mask to determine if the destination host is on the same network as the sending host.

take the Destination IP address and perform a Logical AND operation with destination host's Network Mask to determine if the destination host is on the same network as the sending host.

always forward all packets to the default gateway and not be concerned with determining if the destination host is on the same network as the sending host.

never forward any packets to the default gateway and not be concerned with determining if the destination host is on the same network as the sending host.

In: Computer Science

6) Perform a dihybrid cross for the situation below . - The hair trait has simple...

6) Perform a dihybrid cross for the situation below .

- The hair trait has simple autosomal dominance with hairless dominant over spike hair
- The eyebrow trait is X linked with unibrow dominant over no brows
- Mom is hairless with no brows . Her dad had spiked hair
- Dad is spike haired with a unibrow
* Give the Genotypic Ratio and Phenotypic Ratio for the possible offspring

In: Biology

a) What is the relation between incline angle (0 degrees being flat, and 90 degrees being...

a) What is the relation between incline angle (0 degrees being flat, and 90 degrees being a vertical incline) and acceleration along the incline when friction is not involved?

g*(1-cos(theta)^2); g*sin(theta); g*(1-cos(theta)) or g*cos(theta)

b) When an object is on an incline, what is the relation between the objects weight and the normal force?

m*g*cos(theta); m*g*sin(theta); m*g*(1-cos(theta)) or m*g*(1-cos(theta)^2)

c) What is the force required to make an object under static friction begin motion?

a. the normal force times the coefficient of static friction

b. the normal force times the coefficient of kinetic friction

c. the force due to gravity times the coefficient of kinetic friction

d. mass times the coefficient of static friction

d) What is the relation between the coefficient of kinetic friction and the angle of inclination required to make an object have a constant velocity (no acceleration) going down an incline?

g*m*cos(theta); g*m*cos(theta) - N; tan(theta) or g*(1-cos(theta)^2)

e) The small angle approximation states that sin(theta) can be approximated as what when the angle, theta, is small?

theta in degrees; 1 - theta in radians; 1; or theta in radians

In: Physics

What is the pH of the solution that results from micing 75 mL of 0.50 M...

What is the pH of the solution that results from micing 75 mL of 0.50 M NH3(aq) and 75 mL of 0.50 HCL(aq) at 25 xC? (Kb for NH3 = 1.8x 10-5)

a. 0.60

b 2.67

c. 4.74

d. 4.93

e. 9.26

In: Chemistry