Question: Consider below code fragment that contains a recursive function. Show and explain how does it work? (20 pts) int a[11] = { 10, 14, 19,

Consider below code fragment that contains a recursive function. Show and explain how does it work? (20 pts) int a[11] = { 10, 14, 19, 26, 27, 31, 33, 35, 42, 44, 0 }; int b[10]; void utility(int low, int mid, int high) { int l1, l2, i; for (l1 = low, l2 = mid + 1, i = low; l1 <= mid && l2 <= high; i++) { if (a[l1] <= a[l2]) b[i] = a[l1++]; else b[i] = a[l2++]; } while (l1 <= mid) b[i++] = a[l1++]; while (l2 <= high) b[i++] = a[l2++]; for (i = low; i <= high; i++) a[i] = b[i]; } void function(int low, int high) { int mid; if (low < high) { mid = (low + high) / 2; function(low, mid); function(mid + 1, high); utility(low, mid, high); }

}

This is all for the question.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!