Given an array of integers of any size, n 4, write an algorithm as a pseudo
Question:
Given an array of integers of any size, n ≥ 4, write an algorithm as a pseudo code (not a program!) that would reverse every two consecutive elements of the left half of the array (i.e. reverse elements at index 0 &1, at index 2 & 3, etc.). Additionally, for the right half of the array, the algorithm must change the second element of every two consecutive elements to have to the product (multiplication) of the two elements. For instance, if the right half starts at index 14, and the values at index 14 & 15 are 5 and 12, then the value at index 15 is changed to 60. If the given array is of an odd size, then the left half is considered as the ceiling value of n/2. Finally, your algorithm must use the smallest auxiliary/additional storage to perform what is needed.
b) What is the time complexity of your algorithm, in terms of Big-O?
c) What is the space complexity of your algorithm, in terms of Big-O?
Digital Design and Computer Architecture
ISBN: 978-0123944245
2nd edition
Authors: David Harris, Sarah Harris