Q: Assistance in understanding and solving this example from Data Structure & Algorithms (Computer Science) with...

Q: Assistance in understanding and solving this example from Data Structure & Algorithms (Computer Science) with the steps of the solution to better understand, thanks.

##Using R studio language and code to use provided below, thanks.

In this assignment, we will implement a function to evaluate an arithmetic expression. You will use two stacks to keep track of things. The function is named ‘evaluate’, it takes a string as input parameter, and returns an integer. The input string represents an arithmetic expression, with each character in the string being a token, while the returned value should be the value of the expression.

Examples:

• evaluate ('1+2*3') ➔ 7

• evaluate ('1*2+3') ➔ 5

##This is the code provided to use

"""Basic example of an adapter class to provide a stack interface to

Python's list."""

class ArrayStack:

"""LIFO Stack implementation using a Python list as underlying

storage."""

def __init__ (self):

"""Create an empty stack."""

self._data = [] # nonpublic list instance

def __len__ (self):

"""Return the number of elements in the stack."""

return len (self._data)

def is_empty (self):

"""Return True if the stack is empty."""

return len (self._data) == 0

def push (self, e):

"""Add element e to the top of the stack."""

self._data.append (e) # new item stored at end of

list

def top (self):

"""Return (but do not remove) the element at the top of the stack.

Raise Empty exception if the stack is empty.

"""

if self.is_empty ():

raise Empty ('Stack is empty')

return self._data [-1] # the last item in the list

def pop (self):

"""Remove and return the element from the top of the stack (i.e.,

LIFO).

Raise Empty exception if the stack is empty.

"""

if self.is_empty ():

raise Empty ('Stack is empty')

return self._data.pop () # remove last item from list

class Empty (Exception):

"""Error attempting to access an element from an empty container."""

pass

if __name__ == '__main__':

S = ArrayStack () # contents: [ ]

S.push (5) # contents: [5]

S.push (3) # contents: [5, 3]

print (len (S)) # contents: [5, 3]; outputs 2

print (S.pop ()) # contents: [5]; outputs 3

print (S.is_empty ()) # contents: [5]; outputs False

print (S.pop ()) # contents: [ ]; outputs 5

print (S.is_empty ()) # contents: [ ]; outputs True

S.push (7) # contents: [7]

S.push (9) # contents: [7, 9]

print (S.top ()) # contents: [7, 9]; outputs 9

S.push (4) # contents: [7, 9, 4]

print (len (S)) # contents: [7, 9, 4]; outputs 3

print (S.pop ()) # contents: [7, 9]; outputs 4

S.push (6) # contents: [7, 9, 6]

S.push (8) # contents: [7, 9, 6, 8]

print (S.pop ()) # contents: [7, 9, 6]; outputs 8


In: Computer Science

A bowling ball whose radius R is 0.11 m and whose mass M is 7.2 Kg,...

A bowling ball whose radius R is 0.11 m and whose mass M is 7.2 Kg, rolls from rest down a ramp whose length L is 21 m. The ramp is inclined at an angle θ of 34° to the horizontal ; ( Rotational inertia = ) a) How fast is the center of the ball moving when it reached the bottom of the ramp? Assuming the ball is uniform in density b) What is the kinetic energy associated with rotation and translation as the ball reached the bottom c) What is the angular velocity of the ball as it reached the bottom d) How much time does it take to reach the bottom

In: Physics

What is the difference between cost variance and schedule variance? Describe the four performance indexes mentioned...

  1. What is the difference between cost variance and schedule variance?
  2. Describe the four performance indexes mentioned ?
  3. Define control schedule process, list the control schedule inputs, and list the control schedule tools and techniques

please good answer

In: Computer Science

Shanahan Ltd is registered for VAT and is partially exempt. During the year the company incurred...

  1. Shanahan Ltd is registered for VAT and is partially exempt. During the year the company incurred input tax of £136,000. Of this, £100,000 was attributable to taxable supplies, £13,000 was attributable to exempt supplies and £23,000 was unattributable. The total VAT exclusive value of supplies made by Shanahan Ltd for the year was £975,000. £100,000 of the £975,000 was in respect of zero rated supplies. £80,000 of the £975,000 was from exempt supplies. How much of Shanahan Ltd’s input tax is recoverable?

  1. £113,000
  2. £121,112
  3. £100,000
  4. £87,000

In: Accounting

Q12: Dove Corporation began its operations on September 1 of the current year. Budgeted sales for...

Q12:

Dove Corporation began its operations on September 1 of the current year. Budgeted sales for the first three months of business are $236,000, $310,000, and $403,000, respectively, for September, October, and November. The company expects to sell 25% of its merchandise for cash. Of sales on account, 70% are expected to be collected in the month of the sale and 30% in the month following the sale.

The cash collections in November are

a.$458,490

b.$382,075

c.$211,575

d.$100,750

Q13:

Dove Corporation began its operations on September 1 of the current year. Budgeted sales for the first three months of business are $250,000, $320,000, and $410,000, respectively, for September, October, and November. The company expects to sell 25% of its merchandise for cash. Of sales on account, 70% are expected to be collected in the month of the sale and 30% in the month following the sale.

The cash collections in November are

a.$389,750

b.$410,000

c.$490,000

d.$317,750

Q14:

Production estimates for July are as follows:

Estimated inventory (units), July 1 8,500
Desired inventory (units), July 31 10,500
Expected sales volume (units), July 76,000


For each unit produced, the direct materials requirements are as follows:

Direct material A ($5 per lb.) 3 lbs.
Direct material B ($18 per lb.) 1/2 lb.


The total direct materials purchases of materials A and B (assuming no beginning or ending material inventory) required for July production is

a.$1,170,000 for A; $702,000 for B

b.$1,125,000 for A; $675,000 for B

c.$1,080,000 for A; $648,000 for B

d.$1,080,000 for A; $1,296,000 for B

In: Accounting

A sample of 37 observations is selected from a normal population. The sample mean is 29,...

A sample of 37 observations is selected from a normal population. The sample mean is 29, and the population standard deviation is 5. Conduct the following test of hypothesis using the 0.05 significance level. H0: μ ≤ 26 H1: μ > 26 Is this a one- or two-tailed test? "One-tailed"—the alternate hypothesis is greater than direction. "Two-tailed"—the alternate hypothesis is different from direction. What is the decision rule? (Round your answer to 2 decimal places.)

In: Math

Challenge : The angle of depression from an airplane to the outskirts of a city measures...

Challenge : The angle of depression from an airplane to the outskirts of a city measures 5.8 (degrees Tangent) The airplane is flying 6 miles above the ground at a speed of 200 mi/h. How much time will elapse before the airplane begins passing over the city?

In: Physics

What protective structure allows bacteria from phylum Firmicutes to tolerate extreme conditions such as high temperatures...

What protective structure allows bacteria from phylum Firmicutes to tolerate extreme conditions such as high temperatures or minimal moisture?

Name two chemicals contained within this structure that aid in the protection of these cells.

In: Biology

Post-Lab Questions Which data point can you obtain with greater accuracy from your graph-the pK values...

Post-Lab Questions

Which data point can you obtain with greater accuracy from your graph-the pK values from the "legs" or the isoelectric point from the point of inflection? Explain your answer.

In: Chemistry

A top-loading washing machine has a cylindrical drum that rotates about a vertical axis. The drum...

A top-loading washing machine has a cylindrical drum that rotates about a vertical axis. The drum of one such machine starts from rest and reaches an angular speed of 6.0 rev/s in 12.0 s. The lid of the machine is then opened, which turns off the machine, and the drum slows to rest in 11.0 s. Through how many revolutions does the drum turn during this 23 s interval? Assume constant angular acceleration while it is starting and stopping.

In: Physics

two techniques for implementing a top-down parser: a recursive descent parser and a table-driven parser. a.What...

two techniques for implementing a top-down parser: a recursive descent parser and a table-driven parser.

a.What are the advantages of writing a recursive descent parser instead of a table-driven parser?

b.What are the disadvantages of recursive descent?

In: Computer Science

Hand-to-Mouth (H2M) is currently​ cash-constrained, and must make a decision about whether to delay paying one...

Hand-to-Mouth (H2M) is currently​ cash-constrained, and must make a decision about whether to delay paying one of its​ suppliers, or take out a loan. They owe the supplier $ 11,500 with terms of 1.8​/10 Net​ 40, so the supplier will give them a 1.8 % discount if they pay by today​ (when the discount period​ expires). ​ Alternatively, they can pay the full $ 11,500 in one month when the invoice is due. H2M is considering three​ options:

Alternative​ A: Forgo the discount on its trade credit​ agreement, wait and pay the full $ 11,500 in one month.

Alternative​ B: Borrow the money needed to pay its supplier today from Bank​ A, which has offered a​ one-month loan at an APR of 11.6 %. The bank will require a​ (no-interest) compensating balance of 5.3 % of the face value of the loan and will charge a $ 95 loan origination fee. Because H2M has no​ cash, it will need to borrow the funds to cover these additional amounts as well.

Alternative​ C: Borrow the money needed to pay its supplier today from Bank​ B, which has offered a​ one-month loan at an APR of 14.8 %. The loan has a 0.5 % loan origination​ fee, which again H2M will need to borrow to cover.

In: Accounting

Adamson Corporation is considering four average-risk projects with the following costs and rates of return: Project...

Adamson Corporation is considering four average-risk projects with the following costs and rates of return:

Project Cost Expected Rate of Return
1 $2,000 16.00%
2 3,000 15.00
3 5,000 13.75
4 2,000 12.50

The company estimates that it can issue debt at a rate of rd= 10%, and its tax rate is 30%. It can issue preferred stock that pays a constant dividend of $6 per year at $58 per share. Also, its common stock currently sells for $32 per share; the next expected dividend, D1, is $3.25; and the dividend is expected to grow at a constant rate of 6% per year. The target capital structure consists of 75% common stock, 15% debt, and 10% preferred stock. The data has been collected in the Microsoft Excel Online file below. Open the spreadsheet and perform the required analysis to answer the questions below.

Open spreadsheet

 
WACC and optimal capital budget
Cost of debt, rd 10.00%
Tax rate, T 30.00%
Preferred dividend $6.00
Preferred stock price, Pp $58.00
Common stock price, P0 $32.00
Expected common dividend, D1 $3.25
Common stock constant growth rate, gn 6.00%
% common stock in capital structure 75.00%
% debt in capital structure 15.00%
% preferred stock in capital structure 10.00%
"Cost of capital components & WACC calculation:" Weights After-tax Cost Weighted Cost
After-tax cost of debt, rd(1 – T) 15.00%
Cost of preferred stock, rp 10.00%
Cost of common stock, rs 75.00%
WACC =
Project acceptance analysis:
Projects Cost Expected Rate of Return Accept Project? Y/N
1 $2,000 16.00%
2 $3,000 15.00%
3 $5,000 13.75%
4 $2,000 12.50%
Formulas
"Cost of capital components & WACC calculation:" Weights After-tax Cost Weighted Cost
After-tax cost of debt, rd(1 – T) 15.00% #N/A #N/A
Cost of preferred stock, rp 10.00% #N/A #N/A
Cost of common stock, rs 75.00% #N/A #N/A
WACC = #N/A
Project acceptance analysis:
Projects Cost Expected Rate of Return Accept Project? Y/N
1 $2,000 16.00% #N/A
2 $3,000 15.00% #N/A
3 $5,000 13.75% #N/A
4 $2,000 12.50% #N/A
  1. What is the cost of each of the capital components? Round your answers to two decimal places. Do not round your intermediate calculations.

    Cost of debt %

    Cost of preferred stock %

    Cost of retained earnings %

  2. What is Adamson's WACC? Round your answer to two decimal places. Do not round your intermediate calculations.

    %

  3. Only projects with expected returns that exceed WACC will be accepted. Which projects should Adamson accept?

    Project 1
Project 2
Project 3
Project 4

In: Finance

1. ____ means that a person is required to marry within his or her own social...

1.

____ means that a person is required to marry within his or her own social group.

a.

Endogamy

b.

Polygamy

c.

Exogamy

d.

Affinity

2.

Gender is

a.

universally divided into masculine and feminine

b.

a universal basis for organizing group activities

c.

determined by one’s chromosomes

d.

not an important dimension of a person's social identity

3.

Kinship terminology varies from culture to culture.

True

False

4.

Your father’s sister’s kids are your cross cousins.

True

False

In: Psychology

t (s) [A] (M) ln[A] 1/[A] 0.00 0.500 −0.693 2.00 20.0 0.389 −0.944 2.57 40.0 0.303...

t
(s)
[A]
(M)
ln[A] 1/[A]
0.00 0.500 −0.693 2.00
20.0 0.389 −0.944 2.57
40.0 0.303 −1.19 3.30
60.0 0.236 −1.44 4.24
80.0 0.184 −1.69 5.43

Now that we know it os first order

What is the value of the rate constant for this reaction?

In: Chemistry