Question: 4-2 Parameter-passing costs Throughout this book, we assume that parameter passing during procedure calls takes constant time, even if an N-element array is being passed.

 4-2 Parameter-passing costs Throughout this book, we assume that parameter passing

4-2 Parameter-passing costs Throughout this book, we assume that parameter passing during procedure calls takes constant time, even if an N-element array is being passed. This assumption is valid in most systems because a pointer to the array is passed, not the array itself. This problem examines the implications of three parameter-passing strategies: 1. Arrays are passed by pointer. Time =(1). 2. Arrays are passed by copying. Time =(N), where N is the size of the array. 3. Arrays are passed by copying only the subrange that might be accessed by the called procedure. Time =(n) if the subarray contains n elements. Consider the following three algorithms: a. The recursive binary-search algorithm for finding a number in a sorted array (see Exercise 2.3-6). b. The MERGE-SORT procedure from Section 2.3.1. c. The MatriX-Multiply-Recursive procedure from Section 4.1. Give nine recurrences Ta1(N,n),Ta2(N,n),,Tc3(N,n) for the worst-case running times of each of the three algorithms above when arrays and matrices are passed using each of the three parameter-passing strategies above. Solve your recurrences, giving tight asymptotic bounds

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!