Home / Essays / SCIENCE

SCIENCE

SCIENCE
write an assembly program that uses loops with indirect or indexed
addressing to permutates (re-arranges) an integer array. The following example
shows how an array is re-arranged based on the permutation:
Array before permutation:
0 1 2 3 4 5 6 7 8 9
12 9 54 20 3 38 72 17 91 25
Permutation:
8 3 5 9 2 6 0 4 1 7
Array after permutation:
91 20 38 25 54 72 12 3 9 17
Assuming Permutation[i] = j, the permutation operation re-arranges the original
array such that the jth element of the original array is now stored on the ith position
(i.e., index). For instance, in the above example Permutation[2] is 5. After
permutation, the 5th element in the original array (i.e., 38) is now the 2nd element of
the array.
In your program you are allowed to define only two arrays – one for the array and
the other for the permutation. Do not copy the array elements to any other array!
The runtime screen shot can be as follows (you can use different numbers):
Welcome! This program permutates an array of size 10.
Please enter the 10 elements of your array:
12 9 54 20 3 38 72 17 91 25
The permutated array is:
91 20 38 25 54 72 12 3 9 17
FOR YOUR ASSIGNMENTS TO BE DONE AT A CHEAPER PRICE PLACE THIS ORDER OR A SIMILAR ORDER WITH US NOW

Leave a Reply

WPMessenger