Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a . 2 . 5 + 2 . 5 Please write the following two functions for it . Also describe their time complexity. A is
a Please write the following two functions for it Also describe their time complexity. A is
globallyobjectively accessible to the two functions
def setValue : # sets a value at row and column y in
def subRectangleSumx y x y: # calculates the sum value of rectangle encased #within the
two given point and x y Eg:
Then subRectangleSum returns subRectangleSum returns
Write pseudocode. Explanation of your algorithm and clearly stating and explaining the complexity
are mandatory. b Now very carefully consider this condition. The queries made upon A are in an indefinite stream,
such that you have to execute the two functions repeatedly. If for example, SubRectangleSum
runs in time, that time would be repeated for as long as you have your stream of query
executing. Your goal is to bring the time complexity of the function to You can use an extra
matrix also globally available of the same size. You can also write helper functions to aid you in
the program. Write the new algorithm for helper function and SubRectangleSum The conditions
of writing pseudocode and explanation stand as always.Let
Sigma
Sigma abcz denote the alphabet, and let
Sigma
SSigma
be the set of all words in the English language. In the ScriptoContinua problem, you are given a string
in
Sigma
s in Sigma
n
that does not have any spaces or punctuation marks and you must output True if there exists a sequence of words
in
w
w
m
in S such that
sw
w
w
m
is the concatenation of the words
w
w
m
and False otherwise.
For example, for the input
thisstringisasequenceofwordswrittenwithoutanyspaces
sthisstringisasequenceofwordswrittenwithoutanyspaces
the valid solution is True since we can partition
s into the sequence of words:
thisstringisasequenceofwordswrittenwithoutanyspaces
sthisstringisasequenceofwordswrittenwithoutanyspaces
with
in
w
w
w
in S
Design a dynamic programming algorithm for solving the ScriptoContinua problem. In your solution, you can assume that you have access to an algorithm IsWord that, on any input
in
Sigma
w in Sigma
outputs True if
in
w in S and False otherwise, and has time complexity
Theta
Theta You can create a list of words of approximately words to look through for this you can use a Python dictionary You should aim for an algorithm with runtime
On
aside from the word lookup You do not need to worry about the grammar of the resulting sentence.
Modify the algorithm in part a so that when the answer is True, the algorithm also outputs
in
w
w
m
in S for which
sw
w
w
m
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started