1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alex
2 years ago
12

A contiguous subsequence of a list S is a subsequence made up of consecutive elements of S. For example, if S is 5,15,-30,10,-5,

40,10 then 5,15,-30 is a contiguous subsequence but 5,15,40 is not.
1. Give a linear-time algorithm for the following task:
Input: A list of numbers, A(1), . . . , A(n).
Output: The contiguous subsequence of maximum sum (a subsequence of length zero has sum zero).
For the preceding example, the answer would be 10,-5,40,10 with a sum of 55.
Computers and Technology
1 answer:
Sindrei [870]2 years ago
4 0

Answer:

We made use of the dynamic programming method to solve a linear-time algorithm which is given below in the explanation section.

Explanation:

Solution

(1) By making use of the  dynamic programming, we can solve the problem in linear time.

Now,

We consider a linear number of sub-problems, each of which can be solved using previously solved sub-problems in constant time, this giving a running time of O(n)

Let G[t] represent the sum of a maximum sum contiguous sub-sequence ending exactly at index t

Thus, given that:

G[t+1] = max{G[t] + A[t+1] ,A[t+1] } (for all   1<=t<= n-1)

Then,

G[0] = A[0].

Using the above recurrence relation, we can compute the sum of the optimal sub sequence for array A, which would just be the maximum over G[i] for 0 <= i<= n-1.

However, we are required to output the starting and ending indices of an optimal sub-sequence, we would use another array V where V[i] would store the starting index for a maximum sum contiguous sub sequence ending at index i.

Now the algorithm would be:

Create arrays G and V each of size n.

G[0] = A[0];

V[0] = 0;

max = G[0];

max_start = 0, max_end = 0;

For i going from 1 to n-1:

// We know that G[i] = max { G[i-1] + A[i], A[i] .

If ( G[i-1] > 0)

G[i] = G[i-1] + A[i];

V[i] = V[i-1];

Else

G[i] = A[i];

V[i] = i;

If ( G[i] > max)

max_start = V[i];

max_end = i;

max = G[i];

EndFor.

Output max_start and max_end.

The above algorithm takes O(n) time .

You might be interested in
When someone refers to "space" on a computer or device, they are usually referring to _____, which allows the user to save a fil
Mama L [17]

Answer:

Memory.

Explanation:

When someone refers to "space" on a computer or device, they are usually referring to memory, which allows the user to save a file for future use, even after the computer has been turned off.

In Computer science, a memory is a term used to describe the available space or an electronic device that is typically used for the storage of data or any computer related information such as images, videos, texts, music, codes and folders. There are basically two (2) main types of memory;

1. Read only memory (ROM).

2. Random access memory (RAM).

3 0
3 years ago
Is a book considered technology?
kumpel [21]
Yes, "technology" doesn't have to be all about computers or cell phones.. Technology is anything that is a new advance in knowledge and books were once a great advance in that field.
7 0
3 years ago
Read 2 more answers
Myles is studying a system to lessen the number of complaints about the Help Desk. He has formally studied the service counter a
olga55 [171]

Answer: Informal bench-marking

Explanation:

Informal bench-marking is defined as unconscious comparison of one's own behavior, skills, values etc with other and learning from them to improve. This leaning can be found in work-place, home, school etc.

  • According to the question, Myles is using informal bench-marking through studying other stores complaint handling style and reduction technique so that he can learn from it.
  • Other options are incorrect because designing analysis,outcome analysis, issue analysis and processing of complaining ta re not the comparison that unconsciously done by person .
  • Thus, the correct option is informal bench- marking.
4 0
3 years ago
______ is the ability of a system to do more than one thing at a time. A. Multibusing c. online processing b. Multiprocessing d.
mrs_skeptik [129]

Answer:

Multiprocessing.

Explanation:

In multiprocessing the system uses two or more processors to do more tasks simultaneously.

8 0
2 years ago
Assume that a file contains students' ids, full names, and their scores (Assignments grade, quizzes grade,
elixir [45]

Answer:

اope its heمحبعم

Explanation:

3 0
2 years ago
Other questions:
  • We have a user Sally Smith who we want to grant the ability to launch applications and browse folders. But we do not want her to
    15·1 answer
  • What does CPL stand for
    9·2 answers
  • A network administrator wants to logically separate web servers on the network. Which of the following network device will need
    10·2 answers
  • Answer the following questions: • What is the source of the user’s request? Can a technical solution solve his problem? Perhaps
    10·1 answer
  • Where can you find your EFC
    8·2 answers
  • 1. If an F# function has type 'a -&gt; 'b when 'a : comparison, which of the following is not a legal type for it? Select one:
    14·1 answer
  • What component of a processor holds instructions waiting to be processed by the alu?
    11·1 answer
  • Listening to music on giggl, join!<br><br> link will be in comments, copy and paste
    9·2 answers
  • Josh needs to write a research report for his Civics class. Which file type will allow him to save his file? (5 points)
    12·1 answer
  • Fill in the blanks with the correct words.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!