Problem. Imagine that you have an array of integer valu

Added on - 16 Sep 2019

  • Dissertation

    type

  • 1

    pages

  • 188

    words

  • 43

    views

  • 0

    downloads

Showing pages 1 to 1 of 1 pages
ProblemImagine that you have an array of integer values. Your goal is to swap the two halves ofthe array.Theapproach is tofirst "mirror" the two halves separately and then mirror thewhole array. Mirror means to reverse the elements in an array or partial array, so {1 2 34 5 6} would yield 2 half arrarys {3 2 1}and {654} you then mirror {3 2 1 6 5 4} to get {45 6 1 2 3}.I ask you to follow this approach and implement a function, which is doing themirroring part with the following prototype:void mirror(int* array, int from_index, int to_index);where the two indices define the part of the array which is supposed to be mirrored, in Cnotation (i.e. the first element of the array is at index zero).Need to write comments on every line explaining. The code should be done in C language
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Unlock This Document