Let us consider two sequences of disks(A,B):
m: Length of first sequences of disks
n: Length of second sequences of disks
followings are steps taken two find minimum cost for converting one
sequences of disk to another sequences of disk using dynamic
programming.
1)Declare an arr[m+1][n+1], which arr[i][j] stores minimum cost
of converting sequences of disks A(0,n-1 )into sequences of disks
B(0,m-1).
2)for(i=0.......m)
for(j=0.........n)
(a)if i=0 If first string is empty, only option
is to insert all characters of second string i.e arr[i][j]=n;
(b)if j=0 If second string is empty, the only
option is to remove all characters of first string i.e
arr[i][j]=m;
(c)if last characters of two strings are same,
Ignore last characters and recur for remaining strings.
i.e if(B[i-1]==A[j-1])
arr[i][j]=arr[i-1][j-1];
(e)if the last character is different, consider
all possibilities :-
(i) Insert: value for i and j-1 i.e
arr[i][j-1]
(ii) Remove: value for i-1 and j i.e
arr[i-1][j]
(iii) Replace: value for i-1 and j-1 i.e
arr[i-1][j-1]
now take minimum
of above three possibilities ,also show which type of operation
performed over A.
if arr[i][j-1]
is minimum ,then operation is inserting a character at jth place in
string A.
if arr[i-1][j]
is minimum ,then operation is removing a character at jth place in
string A.
if arr[i-1][j-1]
is minimum .then operation is replacing a character at jth place in
string A.
arr[i][j]=( 1+
min(arr[i][j-1], arr[i-1][j], arr[i-1][j-1]));
}
(3)finally return value at arr[m][n].
Time complexity = O(m*n)
Consider the following problem based on the transformation of a sequence (or collection) of coloured disks...
Consider the following problem based on the transformation of a sequence (or collection) of coloured disks Assume that you have a very large collection of disks, each with an integer value representing the disk colour from the range [0, c. For example, the colour mapping might be: O-red, 1-yellow, 2-blue, 3-pink. ..., c-black For a given sequence of coloured disks e.g., ( 0,1,2,3,4 ), at each time step (or iteration) you are only allowed to perform one of three basic...
In terms of the programming language required, the algorithm needs to be written in pseudocode Dynamic Programming Consider the following problem based on the transformation of a sequence (or collection) of coloured disks Assume that you have a very large collection of disks, each with an integer value representing the disk colour from the range [0, c. For example, the colour mapping might be 0-red. 1-yellow, 2-blue, 3-pink. , c-black For a given sequence of coloured disks e.g., ( 0,1,2,3,4...
i need the solution in pseudo code please. 4 Dynamic Programmii Consider the following problem based on the transformation of a sequence (or collection) of coloured disks. Assume that you have a very large collection of disks, each with an integer value representing the disk colour from the range [0, cl. For example, the colour mapping might be: O-red, 1-yellow, 2-blue, 3-pink,. c-black For a given sequence of coloured disks eg.,0,1,2,3,4), at each time step (or iteration) you are only...
In terms of the programming language required, the algorithm needs to be written in pseudocode Dynamic Programming Consider the following problem based on the transformation of a sequence (or collection) of coloured disks Assume that you have a very large collection of disks, each with an integer value representing the disk colour from the range [0, c. For example, the colour mapping might be 0-red. 1-yellow, 2-blue, 3-pink. , c-black For a given sequence of coloured disks e.g., ( 0,1,2,3,4...
A priority queue is a collection of items each having a priority. A priority queue supports three fundamental operations. You can ask a priority queue whether it is empty. You can insert an item into the priority queue with a given priority. You can remove the item from the priority queue that has the smallest priority. For example, suppose that you start with an empty priority queue and imagine performing the following steps. Insert item "one" with priority 10. Insert...
***JAVA: Please make "Thing" movies. Objective In this assignment, you are asked to implement a bag collection using a linked list and, in order to focus on the linked list implementation details, we will implement the collection to store only one type of object of your choice (i.e., not generic). You can use the object you created for program #2 IMPORTANT: You may not use the LinkedList class from the java library. Instead, you must implement your own linked list...
1. program to use with number 1. 2. Comparing Python and Java Discussion Forum 14 days ago Use the Python IDLE editor to create the source code for the "numberguess.py" pro- gram. This program is in the "Basic Python Pro- gramming" chapter in its "An Example Python Program: Guessing a Number" section. If you mistakenly create syntax errors, find and fix them. Run the program and test it with various values. Refer to the "numberguess.py Program document to see example...
You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...
What is the role of polymorphism? Question options: Polymorphism allows a programmer to manipulate objects that share a set of tasks, even though the tasks are executed in different ways. Polymorphism allows a programmer to use a subclass object in place of a superclass object. Polymorphism allows a subclass to override a superclass method by providing a completely new implementation. Polymorphism allows a subclass to extend a superclass method by performing the superclass task plus some additional work. Assume that...
Construct a flow chart describing the seperation of the mixture and the isolation of each compound in this experiment. (Lab steps/procedures includes for reference) 4. Construct a flow chart describing the separation of the mixture and the isolation of each compound in this experiment. A commonly used method of separating a mixture of organic compounds is known as liquid-liquid extraction. Most reactions of organic compounds require extraction at some stage of product purification. In this experiment you will use extraction...