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
8090 [49]
3 years ago
6

A contiguous subsequence of a list s is a subsequence made up of consecutive elements of s. for instance, if s is

Mathematics
1 answer:
Olenka [21]3 years ago
7 0
<span>contiguous subsequence of a list S is a subsequence made up of consecutive elements of S. For instance, if S is 5; 15;-30; 10;-5; 40; 10; then 15;-30; 10 is a contiguous subsequence but 5; 15; 40 is not. Give a linear-time algorithm for the following task: Input: A list of numbers, a1; a2; : : : ; an. 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. (Hint: For each j =1; 2; : : : ; ng, consider contiguous subsequences ending exactly at position j.) Here is my solution in Python 3. Notes: * If more than one subset equal the maximum value, only the first is returned. * The manner of inputting the list was not specified. The list is hardcoded. * The output was not formatted exactly to specifications. * The preceding points were not improved upon in order to keep the code simple. ______python 3 -- leading dots are spaces for indentation____ def maxSubSeq(seq): ....max_sum = 0 ....max_subseq = [] ....for start in range(len(seq)): ........for end in range(start+1, len(seq)+1): ............subseq = seq[start:end] ............total = sum(seq[start:end]) ............if total > max_sum: ................max_sum = total ................max_subseq = subseq ....return(max_subseq) seq=[5, 15, -30, 10, -5, 40, 10] print(maxSubSeq(seq)) _____Output:_____ [10, -5, 40, 10] _____</span>
You might be interested in
Mrs. Phillips has some cans of peas, beans, corn, and carrots without labels. When a can is chosen randomly, the probability of
sergeinik [125]

Answer:

55

Step-by-step explanation:

6 0
3 years ago
Seung and Razi are both filling party favor bags for their birthdays at a constant rate. Razi’s progress is shown in the table.
Natalka [10]

Answer:

Each minute Seung fills one less bag than Razi.

Step-by-step explanation:

Find the rate of change.

<u>Razi's rate of change:</u>

\dfrac{y(b)-y(a)}{b-a}\\ \\=\dfrac{y(2)-y(1)}{2-1}\\ \\=\dfrac{44-48}{2-1}\\ \\=\dfrac{-4}{1}\\ \\=-4

<u>Seung's rate of change:</u>

\dfrac{y(b)-y(a)}{b-a}\\ \\=\dfrac{y(4)-y(3)}{4-3}\\ \\=\dfrac{31-34}{4-3}\\ \\=\dfrac{-3}{1}\\ \\=-3

This means Razi packs 4 bags per minute, Seung packs 3 bags per minute.

<u>Difference</u> = 4 - 3 = 1 bag

Each minute Seung fills one less bag than Razi.

7 0
3 years ago
Read 2 more answers
Jeremy weigh a cell phone on a digital scale. write down 113 but forget to record the unit.which unit of measurement is correct
Andrew [12]
Hello! Grams would be the correct measurement. One kilogram is equal to about 2.2 pounds. If you cell phone weighed 113 kilograms it would be 249 pounds! The size of an adult!

One gram is about the weight of a paper clip, so it makes more sense for a cell phone to weigh 113 paper clips. 

I hope this helps!
7 0
4 years ago
Read 2 more answers
27 to 32<br> What is the frequency between 27 to 32
hammer [34]

Answer:

it has a frequency of 5

Step-by-step explanation:

8 0
3 years ago
7b−15=5b−3 solve for b
Salsk061 [2.6K]

Step-by-step explanation:

7b-5b=-3+15

2b=12

b=12/2

b=6

8 0
3 years ago
Other questions:
  • Which of the following equations describes the line shown below? Check all
    8·1 answer
  • Mary invested $200 for 3 years at, 596 per
    7·1 answer
  • If the average (arithmetic mean) of 10,20,30,40, and x is 60, what is the value of x​
    15·1 answer
  • Simplify the expression.
    6·2 answers
  • Which statement about the dilation of these triangles is true?
    15·1 answer
  • HELP ME PLEEEAASSEEE I SUCK AT MATH
    8·2 answers
  • If jackeline and Raychel decide to watch only the two longest movies and take a 30 minute break in between how much of their fiv
    7·1 answer
  • Look at the graph of a line and write its equation​
    13·1 answer
  • Gina paid $131 for a car stereo on sale for 30% off. There was also 7% sales tax on the purchase. Find the original price of the
    11·1 answer
  • 1. Jordan scores a 53 on his math test. The class average is 57 with a standard deviation of
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!