Question: Someone please help me with this. Thank you! 1) Trace the execution of the call mystery(6) for the following recursive function. What does this function

Someone please help me with this. Thank you!

1) Trace the execution of the call mystery(6) for the following recursive function. What does this function do?

int mystery (int n) {

if (n == 0)

return 0;

else

return n * n + mystery (n 1);

}

Use a stack (table) to trace the execution and show the details of the recursion process.

2) Answer the following questions

a) Use the random number generator to generate 1000 random integer values. Use these 1000 integers to create 3 arrays.

b) Modify the bubble sort algorithm by adding a counter to count how many times the elements of the array changed value (swapping is considered as a one change)

c) For each array, apply the modified bubble sort algorithms and save the counter value.

d) Repeat step 1 to 4, using shell sort algorithm, quick sort algorithm and merge sort algorithm.

State your observations and conclusion in the space provided belowSomeone please help me with this. Thank you! 1) Trace the execution

Use the results to complete the table below: 1 st array counter 2nd array counter 3rd array counter Bubble sort Shell sort Quick sort Merge sort

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!