Given: You are given a Python Class template. In this class
there is a
class variable vector, is a list of N non-negative integers and
are
stored (in positions 0, 1, 2, ... (N-1)), where at least one
integer
is 0.
Task: Write a recursive function "findAllPaths" to find all
possible
path through V starting at position 0, and ending at
the location of 0, in accordance with the Rule below.
If no such path exists, "paths" should be an empty list. You
also
have to write functions called "getShortest" and "getLongest"
which
return respectively the shortest and longest paths as lists.
Rule: From position i, the next position in the path must be either
i+x,
or i-x, where x is the non-negative integer stored in position
i.
There is no path possible from position i to position i+x if
either of these 2 conditions hold:
position i+x is beyond the end of V.
position i+x is already on the path.
There is no path possible from position i to position i-x if
either of these 2 conditions hold:
position i-x is beyond the start of V.
position i-x is already on the path.
Example:
Suppose V contained the following:
Position: 0 1 2 3 4 5 6 7 8 9 10 11
Integer: 2 8 3 2 7 2 2 3 2 1 3 0
Then one path is:
0 2 5 7 4 11
Recursive Algorithm
-------------------
Your solution MUST use a recursive function to identify the
paths.
You must implement the recursive function, as follows:
def findAllPaths(self, position, solution):
"findAllPaths" takes the initial part of a solution Path,
and
a potential next solution position in the Vector. It explores
paths with the given position appended to the given solution
path so far.
The class variable paths is a list of lists and the function
Example Run:
------------
Example vector: [2, 8, 3, 2, 7, 2, 2, 3, 2, 1, 3, 0]
Valid paths:
0 2 5 7 4 11
0 2 5 3 1 9 10 7 4 11
0 2 5 3 1 9 8 10 7 4 11
0 2 5 3 1 9 8 6 4 11
No Solution example:
3 1 1 1 3 4 2 5 3 0
The following template is given:
def getName():
# Use the name displayed on D2L (easier for us to find)
return "Haque, Mohammad"
class Pathfinder():
def __init__(self, vector):
# Initialize the Pathfinder object
self.vector = vector
self.paths = []
self.findAllPaths(0,[])
def findAllPaths(self, position, solution):
# Recursively explore the possible paths and store valid
paths
# This method will not be tested, so you can modify the parameters
as needed
print("hi")
pass
def getLongest(self):
# Return the longest of all paths found or [] if no paths
exist
# If multiple paths with the longest length exist, return one of
them
pass
def getShortest(self):
# Return the shortest of all paths found or [] if no paths
exist
# If multiple paths with the shortest length exist, return one of
them
pass
Any help will very much appreciated
In: Computer Science
A battery is connected across a series combination of two identical resistors. If the potential difference across the terminals is V and the current in the battery is i, then:
Which of these statement are true?
The potential difference across each resistor is V and the current in each resistor is i
The potential difference across each resistor is V/2 and the current in each resistor is i
The potential difference across each resistor is V and the current in each resistor is i/2
The potential difference across each resistor is V/2 and the current in each resistor is i/2
None of these are true
In: Physics
Put the Cross-Sectional investments algorithm steps in the correct order.
(i) Buy the winners and sell the losers.
(ii) Rank assets based on their performance in the recent K periods.
(iii) Set the look-back period, K.
(iv) Calculate the K-period return for each asset.
(v) Consider the universe of N assets.
Select one:
a.
(iv), (v), (ii), (i), (iii)
b.
(v), (iii), (iv), (ii), (i)
c.
(iii), (v), (iv), (ii), (i)
d.
(v), (iii), (ii), (iv), (i)
In: Finance
An N-Channel device has K’n = 50 µA / V^2, Vt = 0.8 V and W/L = 20. The device is operating as a switch for small Vds, utilizing a control voltage Vgs in the range 0 V to 5 V. Find the switch closures resistance, Rds and closure voltage, Vds obtained when Vgs = 5 V and Id = 1 ma. Recalling that Up (Miu)= 0.4 µ(n). What must W/L be for a p-channel device that provides the same performance as the n-channel device in this application?
In: Electrical Engineering
Please research, Hamer v. Sidway.
After finding and reading the case, please do the following:
1) Give me the legal citation for this case (Hamer v. Sidway).
2) Give me the Issue, Rule, the judge's Analysis, and the judge's Conclusion for Hamer v. Sidway. (In other words: a) What is the main Issue in Hamer v. Sidway; b) What is the main Rule the judge applied to the issue in Hamer v. Sidway; c) What is the judges reasoning (analysis) in using the Rule to arrive at their Conclusion; d) What is the conclusion in this case?
In: Accounting
In: Electrical Engineering
In 2021, the Westgate Construction Company entered into a contract to construct a road for Santa Clara County for $10,000,000. The road was completed in 2023. Information related to the contract is as follows:
| 2021 | 2022 | 2023 | |||||||
| Cost incurred during the year | $ | 2,610,000 | $ | 3,162,000 | $ | 2,230,800 | |||
| Estimated costs to complete as of year-end | 6,390,000 | 2,028,000 | 0 | ||||||
| Billings during the year | 2,100,000 | 3,672,000 | 4,228,000 | ||||||
| Cash collections during the year | 1,850,000 | 3,000,000 | 5,150,000 | ||||||
Westgate recognizes revenue over time according to percentage of completion.
Required:
1. Calculate the amount of revenue and gross profit (loss) to be recognized in each of the three years. (Do not round intermediate calculations. Loss amounts should be indicated with a minus sign.)
In: Accounting
Bob Arnold is a well-known real estate developer in Santa Fe, New Mexico. He wants to remodel a building and convinces George Mitchell, a local businessperson, to contribute the capital to form a partnership. On January 1, 2020, Mitchell invests a building worth $162,000 and equipment valued at $32,000 as well as $25,000 in cash. Although Arnold makes no tangible contribution to the partnership, he will operate the business and be an equal partner in the beginning capital balances.
Required:
(A). Prepare the January 1, 2020 journal entry to record the formation of the partnership assuming the bonus method is used.
(B). Prepare the January 1, 2020 journal entry to record the formation of the partnership assuming the goodwill method is used.
In: Accounting
Required information
In 2018, the Westgate Construction Company entered into a contract
to construct a road for Santa Clara County for $10,000,000. The
road was completed in 2020. Information related to the contract is
as follows:
| 2018 | 2019 | 2020 | |||||||
| Cost incurred during the year | $ | 2,156,000 | $ | 3,388,000 | $ | 2,371,600 | |||
| Estimated costs to complete as of year-end | 5,544,000 | 2,156,000 | 0 | ||||||
| Billings during the year | 2,130,000 | 3,414,000 | 4,456,000 | ||||||
| Cash collections during the year | 1,865,000 | 3,300,000 | 4,835,000 | ||||||
Westgate recognizes revenue over time according to percentage of
completion.
3. Complete the information required below to
prepare a partial balance sheet for 2018 and 2019 showing any items
related to the contract. (Do not round intermediate
calculations.)
In: Accounting
Collins is currently teaching computer age philosophy at MIT, making $85,000 per year. He is considering leaving his job to open up a restaurant in Santa Fe. He estimates that he will need to spend $200,000 per year on space and supplies and $100,000 per year on wages for his staff. The restaurant will earn $340,000 per year in revenue.
Assuming his estimates are accurate, what will Collins’ accounting profit be each year?
Assuming his estimates are accurate, what will Collins’ economic profit be each year?
Explain, beyond just reciting how it is calculated, what economic profit means, and why economists might believe it is a better estimate for the profitability of an economic decision.
In: Economics