Menu

(Solved) : Consider Following Problem Based Transformation Sequence Collection Coloured Disks Assume Q38270902 . . .

Consider the following problem based on the transformation of a sequence (or collection) of coloured disks Assume that you ha

Note: after multiple operations (or iterations), the length of sequence of disks may be different t<o the length of the start

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 operations . remove one disk from the sequence – the disk you select can be any of the disks » insert one disk at any position in the sequence – the disk you select to insert can be any colour in the range 0, c] » replace any single coloured disk in the sequence with a different coloured disk -the replacement disk can be any colour in the range 10. c e.g, (0,1,2,3,4)0,1,2,3,9) Note: after multiple operations (or iterations), the length of sequence of disks may be different t<o the length of the starting sequence. We suggest that you represent each sequence of disks as ain array. (a) 6 marks] Write a dynamic programming implementation for the function: TRANSFORM(Alo..n-11. ΒΟ..m-11) to calculate the minimum number of operations required to transform one given sequence of disks AĮ0..n-1] into another Bl0..m-11. For example, AO, 1, 2, 3, 4] BO, î, 3, 5] requires at least two operations- remove 2; replace 4 by 5 Your function must be written in clear, unambiguous pseudo code. (Hint: consider approximate string search) (b) [2 marks] What is the time complexity of your algorithm? Justify your answer. Show transcribed image text

Expert Answer


Answer to Consider Following Problem Based Transformation Sequence Collection Coloured Disks Assume Q38270902 . . .

OR