Find a contiguous subsequence

Assignment Help Computer Engineering
Reference no: EM133550353

Question 1. Given an ordered sequence of numbers s = {s1,...,sn}, the max-sum problem is to find a contiguous subsequence of s with the greatest sum, that is, a subsequence {si...sj} that maximizes j j max{ E Sk : 1≤i≤n,1≤j ≤n}. k=1 For example, a subsequence of {2,-5,4,1,-2,3} with the greatest sum is {4,1,-2,3}, which has sum 6. (a) Give an efficient algorithm for max-sum that runs in time O(nlogn). (b) Improve your algorithm so that it runs in time Θ(n). 2. Consider the problem of word-wrapping a paragraph of text. A paragraph is an ordered list of n words, where word wi is i letters long. You want to divide the paragraph into a sequence of lines, each containing at most L letters. (No word is more than L letters long.) Suppose a line contains words wi...wj. The total length W(i,j) of this line is defined by j W(i,j) = j -i+ k=i k . This length accounts for a single space between successive pair of words on the line. The slop S(i,j) of this line is defined to be L-W(i,j), the total number of unused spaces at the end of the line. Note that in any feasible solution, the slop of each line must be non-negative. Just to make things concrete, consider the example paragraph "Now is the time for all good men.", and suppose L = 10. One feasible solution is Now is the time for all good men. This solution has four lines of lengths 10, 8, 8, and 4; the corresponding slops are 0, 2, 2, and 6. Your goal is to find a division of the input paragraph into lines that minimizes the sum, over all lines except the last, of the squared slop of each line. (We omit the last line because it can in general be much shorter than the others.) For example, the total cost of the above solution is 02 +22 +22 = 8. Give a polynomial-time algorithm for this problem.

Reference no: EM133550353

Questions Cloud

Which is an incurable disease marked by lung inflammation : It creates a dust that when breathed can cause berylliosis which is an incurable disease marked by lung inflammation and ulceration.
What are the emerging sub-markets and what are the trends : What are the emerging sub-markets? What are the trends? What are the strategic implications of the sub-markets and trends for the major players?
Considering the library system as one information system : Considering the library system as one information system that serves as a very large information storage facility with text, audio, and video data archives
Describe the pathophysiology of crohn disease : Briefly describe the pathophysiology of Crohn's disease. Describe biologic and non-biologic drugs available to treat Crohn's disease.
Find a contiguous subsequence : Find a contiguous subsequence of s with the greatest sum, that is, a subsequence {si...sj} that maximizes j j max
Why is this relevant to brands and businesses today : Why is this relevant to brands & businesses today? What characteristics or traits of the brand make you trust or not trust the brand?
Explaining how low light level limit productivity : Evaluate the reasons for those differences based on the physical properties of the ocean (particularly water density, temperature, light levels and upwelling
Which server should gavin access to find this information : Gavin has been notified that a potential breach may have occurred through the use of a stolen employee login credential. He needs to look at past login
Perform division between x and y : Perform division between x and y and display the value using "long" format. Take a screenshot of your code and the answer to place in the deliverable power

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd