Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

You are given a convex polygon P on n vertices in the plane (specified by their x and y coordinates). A triangulation of P is a collection of n-3diagonals of such that no two diagonals intersect (except possibly at their endpoints). Notice that a triangulation splits the polygon’s interior into n-2 disjoint triangles. The cost of a triangulation is the sum of the lengths of the diagonals in it. Give an efficient algorithm for finding a triangulation of minimum cost. (Hint: Label the vertices of P by 1,....,n, starting from an arbitrary vertex and walking clockwise. For 1i<jn, let the subproblem A(i,j)denote the minimum cost triangulation of the polygon spanned by vertices i,i+1,...,j.).

Short Answer

Expert verified

Convex Polygon: A convex polygon is a close figure whose each interior angle is less than 180°This means that no diagonal can be made which passes outside the boundary of polygon.

Step by step solution

01

Defining the Recursive Equation of Minimum Cost Triangulation

We will make our recursive equation in such a way that no diagonal cross eachother. For numbering, we will follow clockwise direction.

If Ai,jdenote minimum cost triangulation, where i,jare different vertices, Then i,i=0as we cannot make diagonal using same vertice.

Thus, Recursive Equation is:

localid="1657271470951" Ai,j=0minikjAi,k+Ak,j+di,k+dk,j0;ifi=j

Now it is important to define the length of diagonal(d). It is given as:

di,j=xi-xj2+yi-yj220;otherwise;ifj-i2

02

Implementing Algorithm

The algorithm would be as follows:

fori=0tonAi,j=0form=1ton-1fori=1ton-mj=i+mminikjAi,j+Ak,j+di,k+dk,j

returnA1,n

03

Analyse the Algorithm

Now, the outer for loop takes0ntime to compute each of the entry ofAi,j

The two nested loop takes 0n2time. So the effective time complexity will be0n3.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

You are given a string of n characters s[1...n], which you believe to be a corrupted text document in which all punctuation has vanished (so that it looks something like “itwasthebestoftimes...”). You wish to reconstruct the document using a dictionary, which is available in the form of a Boolean function dict(.): for any string w,

dict(w)={trueifwisavalidwordfalseotherwise

Give a dynamic programming algorithm that determines whether the string s[.]can be reconstituted as a sequence of valid words. The running time should be at mostO(n2) , assuming calls to dict take unit time.

In the event that the string is valid, make your algorithm output the corresponding sequence of words.

Local sequence alignment. Often two DNA sequences are significantly different, but contain regions that are very similar and are highly conserved. Design an algorithm that takes an input two strings x[1Kn]and y[1Km]and a scoring matrix δ(as defined in Exercise 6.26), and outputs substrings x'andy'of x and y respectively, that have the highest-scoring alignment over all pairs of such substrings. Your algorithm should take time O(mn).

Counting heads. Given integersn and k, along with p1,...,pn[0,1], you want to determine the probability of obtaining exactly heads when biased coins are tossed independently at random, where pi is the probability that the ith coin comes up heads. Give an 0(n2)algorithm for this task. Assume you can multiply and add two numbers in [0,1]in 0(1)time.

Give an O(nt) algorithm for the following task. Input: A list of n positive integers a1,a2,...,an; a positive integer t. Question: Does some subset of the ai’s add up to t? (You can use each ai at most once.) (Hint: Look at subproblems of the form “does a subset of{a1,a2,...,ai} add up to ?”)

Reconstructing evolutionary trees by maximum parsimony. Suppose we manage to sequence a particular gene across a whole bunch of different species. For concreteness, say there are n species, and the sequences are strings of length k over alphabet={A,C,G,T}. How can we use this information to reconstruct the evolutionary history of these species?

Evolutionary history is commonly represented by a tree whose leaves are the different species, whose root is their common ancestor, and whose internal branches represent speciation events (that is, moments when a new species broke off from an existing one). Thus we need to find the following:

• An evolutionary tree with the given species at the leaves.

• For each internal node, a string of length K: the gene sequence for that particular ancestor.

For each possible tree T annotated with sequencess(u)kat each of its nodes , we can assign a score based on the principle of parsimony: fewer mutations are more likely.

localid="1659249441524" score(T)=(u.v)E(T)(numberofpositionsonwhichs(u)ands(v)disagree)

Finding the highest-score tree is a difficult problem. Here we will consider just a small part of it: suppose we know the structure of the tree, and we want to fill in the sequences s(u) of the internal nodes u. Here’s an example with k=4 and n=5:


(a) In this particular example, there are several maximum parsimony reconstructions of the internal node sequences. Find one of them.

(b) Give an efficient (in terms of n and k ) algorithm for this task. (Hint: Even though the sequences might be long, you can do just one position at a time.)

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free