Given an array A = [2, 6, -1, 8, 0] and an operation called flip which runs in O(1) in hypothetical machine. sort the array. flip operation for array A = [2, 6, -1, 8, 0] A.flip(0)=[0, 8, -1, 6, 2] A.flip(3)=[2, 6, -1, 0, 8] A.flip(2)=[2, 6, 0, 8, -1] try doing in O(nlogn), Please let me know if question is not clear. |