Biologsts often construct a food network of species in an ecosystem. The vertice
ID: 3731407 • Letter: B
Question
Biologsts often construct a food network of species in an ecosystem. The vertices represent species, and a directed edge (u, v) means species u eats species v. Determine the effect of the extinction of a species. If a species v goes extinct, and there is some other species u that only eats v, then u will become extinct. This can cascade through the food network Given a food network and a species v, determine all other species that will become extinct if v goes extinct. Show pseudocode and work out the running time.Explanation / Answer
Find_Ext(species v){
Danger_list +={All species eating species v}
foreach(Danger_list)
If(Selected species eats other species than species v)
{
remove from Danger_list
}
foreach(Danger_list)
{
Find(Selected species, food network) //recursion
}
}
The above pseudocode populates a list with Species that are directly or indirectly dependent on species v.
The running time will be n*n where n is total no of species in food network.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.