Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please help with kruskal alogrithm, providing wrong output, Im not sure what I did wrong. def kruskal ( edges ) : if parent [ i
please help with kruskal alogrithm, providing wrong output, Im not sure what I did wrong. def kruskaledges: if parenti i: else:def unionparent rank, x y: yroot findparent y parentxroot yroot parentyroot xroot parentyroot xroot# Extract vertices from edgesfor edge in edges:s rank parentnode nodeedges sortededges keylambda item: item u v w edge y findparent v sappendedgereturn sorteds keyambda x: x x xFinding the most likely mutation tree
You're given a list of bacteria RNA fragments, all from related bacteria which have mutated into separate strains over time. Your goal is to come up with the most likely sequence of mutations that led to this state of affairs.
The chance that one bacteria mutated into another depends on the number of differences in their RNA strings. The more differences in their RNA strings, the more unlikely it is that the bacteria mutated into each other. In fact, exponentially more unlikely the probability that k locations changed at the same time is
If we construct a fully connected graph whose nodes represent RNA fragments and each edge has weight
where k is the number of differences between RNA strings, then a spanning tree which maximizes the product of edge weights will be the most likely mutation tree. Each mututation is assumed to be independent, so the chance that all the mutations in the spanning tree happen is the product of their respective probabilities
Write a function that takes a list of RNA fragments, constructs an edge list with weights, then returns the most likely mutation tree, along with its probability.
Note: your algorithm should construct a graph and then run your implementation of Kruskal's algorithm on it The difficulty lies in determining the correct graph, so that a minimum sum spanning tree in your graph corresponds to a maximum product spanning tree in the graph described above.
Input: adad"adac","acad", "cdac","addd"
Output: adad 'adac', adad 'acad', adad 'addd', adac 'cdac',
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started