•  
      tasks #44029 Reversal algorithm for array rotation
    #44029
    Ritish Singh (ritish31)
    2022-08-05 10:23
    2022-08-05 10:23
    Details
    Reversal algorithm for array rotation
    For this task, we use the Reversal Algorithm, the main logic behind this algorithm is to reverse the array in parts to get the desired output.
    Input arr[ ] = [1, 2, 3, 4, 5, 6, 7], d = 2, n =7 A[ ] and B[ ] are parts of the array arr[ ] where
    1) A[ ] has elements in the index range 0 to d A[ ] = [1, 2]
    2) B[ ] has elements in the index range d to n B[ ] = [3, 4, 5, 6, 7]
    3) Reverse array A[ ] Ar[ ] = [2, 1] then array ArB=[2, 1, 3, 4, 5, 6, 7]
    4) Reverse array B[ ] Br[ ] = [7, 6, 5, 4, 3] then array ArBr = [2, 1, 7, 6, 5, 4, 3]
    5) Reverse array ArBr[ ] (ArBr)r[ ] = [3, 4, 5, 6, 7, 1, 2]
    6) arr[ ] = [3, 4, 5, 6, 7, 1, 2]
    5 - Medium
    State of Progress
    2022-05-04
    100
    2022-05-06
    Ritish Singh (ritish31)
    Rakesh Kumar Verma (rakesh.verma)
    2022-05-06
    Closed
    Attachments
    References
    References list is empty