I need to find the kth smallest element in the union of 2 sorted arrays in O(log |A| + log |B|) time. I understand this is similar to binary search, but I don't understand which parts of the arrays I can throw out at each level of recursion, and why. In the pseudocode below, what should go into $1 through $16 and why?
// A and B are each sorted into ascending order, and 0 <= k
< |A|+|B|
// Returns the element that would be stored at index k if A and B
were
// combined into a single array that was sorted into ascending
order.
select (A, B, k)
return select(A, 0, |A|-1, B, 0, |B|-1, k)
select(A, loA, hiA, B, loB, hiB, k)
// A[loA..hiA] is empty
if (hiA < loA)
return B[k-loA]
// B[loB..hiB] is empty
if (hiB < loB)
return A[k-loB]
// Get the midpoints of A[loA..hiA] and
B[loB..hiB]
i = (loA+hiA)/2
j = (loB+hiB)/2
// Figure out which one of four cases
apply
if (A[i] > B[j])
if (k <= i+j)
return select(A, $1, $2, B, $3, $4, k);
else
return select(A, $5, $6, B, $7, $8,
k);
else
if (k <= i+j)
return select(A, $9, $10, B, $11, $12, k);
else
return select(A, $13, $14, B, $15, $16, k);
In: Computer Science
One of your mechanics (who was hired from a competitor’s airline) told your maintenance chief he left his former employer over their “pencil maintenance” of aircraft. He explains that they were logging in repairs and upgrades that were not actually being done and the airline is “an accident waiting to happen.” Your maintenance chief would like to report this to the executive committee but has come to you first. The airline was a competitor of yours in the past and is likely to be again in the future. What should you do about this, if anything?
Full Text Your maintenance chief has reported that a mechanic you hired from another regional airline told him that the other airline did a lot of “pencil maintenance.” That is, they wrote a lot of things in the maintenance logs that did not actually get done—required inspections, repairs, and parts replacements. He said, “The outfit is just a big accident, waiting to happen.” Your maintenance chief wanted to report it to the executive committee to see what, if anything should be done. He stated that the mechanic reported that he quit that airline because he did not like to be associated with such an activity. The other airline has competed against you in the past and is likely to compete in at least one market in the future. It has a reputation of being a very aggressive competitor.
Which of the following actions should you take?
1. Report the incident to the authorities. (The other airline will be able to ascertain who made the report.)
2. Phone the president of the other airline and tell him what you heard. You are on neutral terms with that person as he is your competitor.
3. Drop a tip to the local investigative reporter at the newspaper.
4. Report it to an official of the Airline Association. You cannot be sure the official or the association will take any action, but at least your conscience will be clear. It is somewhat possible your name might be leaked to the competitor.
5. You determine that either (a) the matter is none of your business or (b) that the report is just “sour grapes” from a disgruntled employee. So you decide to do nothing.
In: Operations Management
Write a new program named Bar that prompts the user to enter a positive integer. The program should then display a line consisting of the entered number of asterisks using a while loop. If the user enters a number that is not positive, the program should display an error message (see example below).
Example 1: Enter a positive number: 6 ******
Example 2: Enter a positive number: 11 ***********
Example 3: Enter a positive number: -4 -4 is not a positive number
In: Computer Science
Choose a disorder their either typically manifests itself in adolescence, or becomes more problematic in adolescence, and outline the diagnostic criteria for the class using examples.
In: Psychology
A student is ready to graduate if his GPA is at least 2.0 and he is in his fourth year. Write a C++ program that will ask the student about his GPA and what year he is currently in. The program should display a message saying either the student is ready to graduate or he still needs more schooling. This program must be in C++ and must be able to run.
Thank you and I hope you have a great day!
In: Computer Science
The following payments are made under an annuity: 12 at the end
of the 44th year, 11 at the end of the 55th year, decreasing by 11
each year until nothing is paid. Find the present value if the
annual effective rate of interest is 3%.
In: Finance
Is the argument valid? Use rules of inference and laws of logic to prove or disprove (no Truth tables)
1. If John has talent and works very hard, then he will get a job. If he gets a job, then he’ll be happy. Hence if John is not happy, then he either not worked very hard or does not have talent.
2.For spring break Marie will travel to Cancun or Miami. If she goes to Cancun, she will not visit the Miami Zoo. If she does not visit the Miami Zoo she will visit the Cancun Zoo. She did not go to Miami. Therefore she visited the Cancun Zoo.
3. When interest rates go up, then car prices go down. Car prices did not go down. Therefore interest rates went up.
4. Mary plays tennis or Mary plays golf. Therefore, Mary plays golf.
In: Advanced Math
The student will start their own airline company. The student will then: Determine the vision of the company as a start-up. Next, what key moves will the student make to strive to be number one in the industry. Lastly, what different challenges may you encounter and what will be some of the solutions you will implement.
In: Operations Management
In: Operations Management
Please use a switch statement to tell the user that his work is great, good, satisfactory, or he barley passed based on his grade (A : great work, B : good, C: satisfactory, D: Barley passed) This program must be in C++ and must be able to run.
Thank you and I hope you have a great day!
In: Computer Science
A Japanese restaurant chain in the United States is celebrating its twenty-fifth anniversary next year. The owners of the chain see this as an opportunity to garner publicity and perhaps motivate more Americans to patronize the local franchise.
What activities and special events would you recommend to attract media coverage?
In: Operations Management
In: Chemistry
Fuzzy Restaurant is considering the purchase of a $1,500,000 flat top grill. The grill has an economic life of 8 years and will be fully depreciated using straight line method. The grill is expected to produce 59,000 tacos per year for the next 8 years, with each costing $1.50 to make and priced at $5. Assume the discount rate is 8% and the tax rate is 21%. The restaurant expects the market value of the grill to be $200,000, 8 years from now. Calculate the book value of the grill at the end of year 5. (Round to 2 decimals) Calculate the operating cash flow at the end of year 1. Calculate the net present value.
In: Finance
Thank you all. my other code is working fine. It was my IDE issue.
This is the new code i am writing for the below question. please help as you always do:
a=int(input('Input a: '));
b=int(input('Input b: '));
c=int(input('Input c: '));
r=int(input('Input r: '));
s=int(input('Input s: '));
t=int(input('Input t: '));
x=2;
min_rst = min(r,s,t);
while(1):
if((x-a)%r==0):
if((x-b)%s==0):
if((x-c)%t==0):
break;
x=x+1;
print('The required number is: ',x);
Questions:
Write a Python program called crt.py
that finds the value of x that satisfies a system of congruencies
of the form:
x ≡ a (mod r)
x ≡ b (mod s)
x ≡ c (mod t)
where a, b, and c are integers; and r, s, and t are pairwise
relatively prime positive
integers (i.e., gcd(r, s) = gcd(s, t) = gcd(r, t) = 1). Your
program
prompts the user for the values of a, b, c, r, s, and t, and
outputs the value of
x that satisfies the system of congruencies. Hint: see the NumPy
Ntheory class
reference: http://docs.sympy.org/dev/modules/ntheory.html. Submit
your Python
source code crt.py.
Thank you
In: Computer Science
Royal Corp’s financial information (in millions, except
for Dividends) for Problems 2 and 3:
2019 2018
Accounts
Payable $ 7,000 $ 6,780
Accounts Receivable 5,000 4,685
Additional Paid-in Capital 4,000 4,000
Cash 8,577 5,654
Common Stock 3,107 3,107
Cost of Goods Sold 48,464 47,594
Depreciation 1,315 1,244
Dividends per share 1.53 1.28
Goodwill 18,051 19,121
Interest Expense 1,200 1,100
Inventory 8,871 8,101
Long-Term Debt ? ?
Net Property, Plant & Equipment 26,500 25,311
Notes Payable 4,200 3,770
Research & Development Expense 1,847 1,747
Retained Earnings ? 23,045
Revenue 61,200 59,000
Selling General & Admin Expense 3,200 3,024
Shares Outstanding 1,170 1,280
Treasury Stock (6,500) (4,200)
Tax Rate = 30%
Note that a reduction in Goodwill would be similar to Depreciation Expense in a firm’s Operating Cash Flow.
2. See the last page for the financial information of Royal Corporation.
2 A. Construct Income Statements for 2018 and 2019
2019 2018
2B. Construct Balance Sheets for 2018 and 2019
Assets Liabilities
and Owners’ Equity
2019 2018 2019 2018
2C. Construct a 2019 Statement of Cash Flows (Goodwill reduction is
a noncash expense)
In: Accounting