CSCC73H3 Lecture Notes - Substring, Glossary Of Ancient Roman Religion, Dynamic Programming

76 views6 pages
19 Oct 2011
School
Course

Document Summary

M [i] = maximum number that is the sum of a contiguous subsequence of s that ends in position i. We claim that the following is a recursive formula to compute m [i] for all i [1n]. M [i] =(s[1], max(s[i], s[i] + m [i 1]), if i = 1 if i > 1. For i > 1, let xi be the contiguous subsequence of s that ends in position i and has the maximum possible sum among all such subsequences. Thus, xi = ys[i], where y is the (possibly empty) pre x of xi up to and excluding the last element, s[i]. Then xi = s[i] and obviously m [i] = s[i]. y is nonempty. Therefore, y is a contiguous subsequence of s that ends in position i 1 (otherwise. Case 2. xi would not be a contiguous subsequence of s that ends in position i). So, y = xi 1 and therefore xi = xi 1s[i].

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions