Question: 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  Please directly show me the steps and results, negative vote for

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!