Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please directly show me the steps and results, negative vote for incomplete or incorrect answers Improving the code Once you have developed an algorithm, you

Please directly show me the steps and results, negative vote for incomplete or incorrect answers image text in transcribed
Improving the code Once you have developed an algorithm, you will often find that you can improve on the time or space it uses. Some changes can simplify the code and improve constant factors but otherwise yield no asymptotic improvement in performance Others can yield substantial asymptotic savings in time and space In the LCS algorithm, for example, we can eliminate the b table altogether. Each c[i.j] entry depends on only three other c table entries: c [1-1, j-1], c[i-1, j], and c[i. j -1]. Given the value of c[i. j], we can determine in O(1) time which of these three values was used to compute ci, j], without inspecting table b. Thus, we can reconstruct an LCS in O(m+n) time using a procedure similar to PRINT-LCS Exercise 15.4-2 asks you to give the pseudocode.) Although we save (mn) space by this method, the auxiliary space requirement for computing an LCS does not asymptotically decrease, since we need (mn) space for the c table anyway We can, however, reduce the asymptotic space requirements for LCS-LENGTH, since it needs only two rows of table c at a time: the row being computed and the previous row. (In fact, as Exercise 15.4-4 asks you to show, we can use only slightly more than the space for one row of c to compute the length of an LCS.) This improvement works if we need only the length of an LCS; if we need to reconstruct the elements of an LCS, the smaller table does not keep enough information to retrace our steps in O(m) time Exercises 15.4-1 Determine an LCS of,0,0, 1,0,1,0,1) and (0,1,0,0,1,1,0)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+2. How familiar is the audience with the source?

Answered: 1 week ago

Question

Guidelines for Informative Speeches?

Answered: 1 week ago